2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
25 //When element is first created it should have a red box because it hasn't been edited
26 function newElementProcessor(id) {
27 if ($('g[data-element-id="' + id + '"]').length > 0) {
29 var _idNode = $('g[data-element-id="' + id + '"]')
30 _idNode.children("rect").each(function() {
31 if ($(this).attr('class') === 'djs-outline') {
32 $(this).attr('class', "djs-outline-no-property-saved")
33 $(this).attr('fill', 'red')
40 function saveProperties(form) {
41 elementMap[lastElementSelected] = form;
42 totalJsonProperties = JSON.stringify(elementMap);
44 //Take off the red border because the element has been edited
45 if ($('g[data-element-id="' + lastElementSelected + '"]').length > 0) {
46 var _idNode = $('g[data-element-id="' + lastElementSelected + '"]')
47 _idNode.children("rect").each(function() {
48 if ($(this).attr('class') === 'djs-outline-no-property-saved') {
49 $(this).attr('class', "djs-outline")
50 $(this).attr('fill', 'none')
56 function saveGlobalProperties(form) {
57 elementMap["global"] = form;
59 var isObject = function(a) {
60 return (!!a) && (a.constructor === Object);
63 function loadPropertyWindow(type) {
65 if ($("#add_one_more").length == 1) {
66 $("#add_one_more").off();
67 $("#add_one_more").click(function(event) {
68 event.preventDefault();
71 $("input,#savePropsBtn").attr("disabled", "");
72 $(".modal-body button").attr("disabled", "");
73 ($("select:not([multiple])")).multiselect("disable");
76 var props = defaults_props[type];
79 if (isObject(props[p])) {
80 var mySelect = $('#' + p);
81 if (p == "operator") {
82 $.each(props[p], function(val, text) {
84 $('<option></option>').val(val).html(val)
88 $.each(props[p], function(val, text) {
90 $('<option></option>').val(val).html(text)
96 var ms = new Date().getTime();
97 props[p] = "Policy" + ms;
99 $("#" + p).val(props[p])
102 setTimeout(function() {
103 setMultiSelect(type);
110 function setMultiSelect() {
111 $("select").each(function(index, mySelect) {
113 var mySelectObj = $(mySelect);
114 if (! mySelectObj.parents(".multiselect-native-select")) {
115 // keep native for this one
119 if (mySelectObj.parents(".multiselect-native-select").length > 0) {
120 var selectDrop = mySelectObj.parent(".multiselect-native-select").find("select");
121 mySelectObj.parent(".multiselect-native-select").parent().html(selectDrop);
129 if (mySelectObj.attr("multiple")
130 && mySelectObj.attr("multiple") != 'false') {
131 options.includeSelectAllOption = true;
134 if (mySelectObj.attr("enableFilter")
135 && mySelectObj.attr("enableFilter") != 'false') {
136 options.enableCaseInsensitiveFiltering = true;
137 options.enableFiltering = true;
140 mySelectObj.multiselect(options);
144 function loadSharedPropertyByService(onChangeUUID, refresh, callBack) {
148 function loadSharedPropertyByServiceProperties(callBack) {
152 url: '/restservices/clds/v1/clds/properties/',
153 success: function(data) {
154 vf_Services = JSON.parse(data);
156 if (callBack && _.isFunction(callBack)) {
160 error: function(s, a, err) {
161 $('#servName').text($("#service option:selected").text());
162 if (callBack && _.isFunction(callBack)) {
171 function setASDCFields() {
173 var location_values = defaults_props['global']['location'];
174 if (location_values) {
175 for (key in location_values) {
176 if ($("#location").length > 0) {
177 $("#location").append("<option value=\"" + key + "\">" + location_values[key] + "</opton>")
180 $("#location").multiselect("rebuild");
183 var actionSet_values = defaults_props['global']['actionSet'];
184 if (actionSet_values) {
185 for (key in actionSet_values) {
186 if ($("#actionSet").length > 0) {
187 $("#actionSet").append("<option value=\"" + key + "\">" + actionSet_values[key] + "</opton>")
190 $("#actionSet").multiselect("rebuild");
192 if ($("#location").length > 0 && !location_values) {
196 function showWarn() {
197 $("#paramsWarn").show();
198 $('#servName').text($("#service option:selected").text());
206 //Typically used when opening a new model/template
207 function reloadDefaultVariables(isTemp) {
212 $(window).on('load',function() {
215 url: '/restservices/clds/v1/clds/properties',
216 success: function(data) {
217 defaults_props = JSON.parse(data);
219 error: function(s, a, err) {