1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | 1 1 1 1 1 1 1 1 1 1 1 1 1 | 'use strict'; ;require.register("views/common/modal_popups/dependent_configs_list_popup", function (exports, require, module) { /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var App = require('app'); App.DependentConfigsTableView = Em.View.extend({ templateName: require('templates/common/modal_popups/dependent_configs_table'), recommendations: [], isClickable: false, showPopovers: true, elementsWithPopover: function () { return this.$('td.config-dependency-name'); }.property(), hideMessage: function () { return this.get('controller.isInstallWizard'); }.property('controller.isInstallWizard'), updateRecommendedDefault: function () { if (this.get('controller.isInstallWizard')) { var applyRecommendations = this.get('recommendations').filterProperty('saveRecommended'); var dontApplyRecommendations = this.get('recommendations').filterProperty('saveRecommended', false); this.get('controller').undoRedoRecommended(applyRecommendations, true); this.get('controller').undoRedoRecommended(dontApplyRecommendations, false); } }.observes('recommendations.@each.saveRecommended'), isEditable: true, title: Em.computed.ifThenElse('isEditable', Em.I18n.t('popup.dependent.configs.table.recommended'), Em.I18n.t('popup.dependent.configs.table.required')), message: function () { var message = ''; if (this.get('isEditable')) { if (this.get('parentView.isAfterRecommendation')) { message += Em.I18n.t('popup.dependent.configs.title.recommendation') + '<br>'; } message += Em.I18n.t('popup.dependent.configs.title.values'); } else { message += Em.I18n.t('popup.dependent.configs.title.required'); } return message; }.property('isEditable'), didInsertElement: function didInsertElement() { if (this.get('showPopovers')) { App.popover(this.get('elementsWithPopover'), { placement: 'auto right', trigger: 'hover', html: true }); } }, willDestroyElement: function willDestroyElement() { if (this.get('showPopovers')) { this.get('elementsWithPopover').popover('destroy'); } } }); App.DependentConfigsListView = Em.View.extend({ templateName: require('templates/common/modal_popups/dependent_configs_list'), isAfterRecommendation: true, isRecommendationsClickable: false, showRecommendationsPopovers: true, recommendations: [], requiredChanges: [], allConfigsWithErrors: [], toggleAllId: '', toggleAll: App.CheckboxView.extend({ didInsertElement: function didInsertElement() { this.set('parentView.toggleAllId', this.get('elementId')); this.updateCheckbox(); }, click: function click() { Em.run.next(this, 'updateSaveRecommended'); }, updateCheckboxObserver: function () { Em.run.once(this, 'updateCheckbox'); }.observes('parentView.recommendations.@each.saveRecommended'), updateCheckbox: function updateCheckbox() { this.set('checked', !(this.get('parentView.recommendations') || []).someProperty('saveRecommended', false)); }, updateSaveRecommended: function updateSaveRecommended() { this.get('parentView.recommendations').setEach('saveRecommended', this.get('checked')); } }), setAllConfigsWithErrors: function () { if (this.get('state') === 'inBuffer' || Em.isNone(this.get('controller.stepConfigs'))) { return; } this.set('allConfigsWithErrors', this.get('controller.stepConfigs').reduce(function (result, stepConfig) { if (stepConfig.get('configsWithErrors.length')) { result = result.concat(stepConfig.get('configsWithErrors')); } return result; }, [])); }.observes('controller.stepConfigs.@each.configsWithErrors'), didInsertElement: function didInsertElement() { $('span.dropdown-toggle').dropdown(); this.setAllConfigsWithErrors(); this._super(); } }); /** * Show confirmation popup * @param {[Object]} recommendations * @param {[Object]} requiredChanges * @param {function} [primary=null] * @param {function} [secondary=null] * @param {boolean} [isRecommendationsClickable=false] * @param {boolean} [isRecommendationsClickable=true] * we use this parameter to defer saving configs before we make some decisions. * @return {App.ModalPopup} */ App.showDependentConfigsPopup = function (recommendations, requiredChanges, primary, secondary, controller) { var isRecommendationsClickable = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false; var showRecommendationsPopovers = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true; return App.ModalPopup.show({ encodeBody: false, header: Em.I18n.t('popup.dependent.configs.header'), classNames: ['common-modal-wrapper'], modalDialogClasses: ['modal-xlg'], secondaryClass: 'cancel-button', bodyClass: App.DependentConfigsListView.extend({ recommendations: recommendations, requiredChanges: requiredChanges, controller: controller, isRecommendationsClickable: isRecommendationsClickable, showRecommendationsPopovers: showRecommendationsPopovers }), saveChanges: function saveChanges() { recommendations.forEach(function (c) { Em.set(c, 'saveRecommendedDefault', Em.get(c, 'saveRecommended')); }); }, discardChanges: function discardChanges() { recommendations.forEach(function (c) { Em.set(c, 'saveRecommended', Em.get(c, 'saveRecommendedDefault')); }); }, onPrimary: function onPrimary() { this._super(); if (primary) primary(); this.saveChanges(); }, onSecondary: function onSecondary() { this._super(); Eif (secondary) secondary(); this.discardChanges(); }, onClose: function onClose() { this.onSecondary(); } }); }; }); |