· 4 years ago · Mar 17, 2021, 02:38 PM
1/********************** Written By Santosh **********************/
2/********************** Writed By RK **********************/
3Drupal.behaviors.hp_apps_product = {
4 attach: function (context, settings) {
5 $("#hp-my-apps-create-form #edit-hp-my-apps-add-form-app-display-name").on('keyup', function () {
6 var date = new Date();
7 var timestamp = date.getTime();
8 var displayName = this.value + timestamp;
9 if (/^[a-zA-Z0-9 ]*$/.test(displayName) == false) {
10 string = displayName.replace(/[^a-zA-Z0-9 ]/g, '');
11 $("#edit-hp-my-apps-add-form-app-unique-name").val(string);
12 } else {
13 $("#edit-hp-my-apps-add-form-app-unique-name").val(displayName);
14 }
15 });
16 var json_Product_Data_Array = Drupal.settings.hp_apps_product.jsonProductDataArray;
17 var json_Category_Product_Data = Drupal.settings.hp_apps_product.jsonCategoryProductData;
18 var all_key_category = Drupal.settings.hp_apps_product.allKeyCategory;
19 var taxnomy_terms = Drupal.settings.hp_apps_product.txnterms;
20 if (taxnomy_terms && taxnomy_terms.length > 0) {
21 var cleanProName = taxnomy_terms[0].displayName.toLowerCase().replace(/ /g, '').replace(/["'\(\)]/g, "").replace(/-/g, '').trim();
22 var authZprodID = cleanProName+'_'+taxnomy_terms[0].unique_key;
23 }else{
24 var authZprodID = '';
25 }
26
27
28 //alert( JSON.stringify(json_Product_Data_Array));
29 //console.log("json_Product_Data_Array => : "+ JSON.stringify(json_Product_Data_Array));
30 //console.log("json_Category_Product_Data => : "+ JSON.stringify(json_Category_Product_Data));
31 //console.log("all_key_category => : "+ JSON.stringify(all_key_category));
32
33 /********************** Written By Santosh Start **********************/
34 let addProduct = false;
35 let jda_Data_Details =[];
36 let jda_Data, jda_data_apiProducts;
37 let jda_apiProducts=[];
38 //let jda_data_environments = [];
39 //let jda_data_bundling = [];
40 let jda_data_environments = '';
41 let jda_data_bundling = '';
42 let jda_data_HpIdEnabled;
43 let seleted_pro_approvalType = [];
44
45 if (window.location.href.indexOf("add-products") > -1) {
46 addProduct = true;
47 //alert("your url contains the name franky");
48 }
49 //console.log("add-Product => : "+ addProduct)
50
51 /******** For Add Product **********************/
52 if(addProduct){
53 var json_Developer_App = Drupal.settings.hp_apps_product.jsonDeveloperApp;
54 jda_Data = JSON.parse(json_Developer_App);
55 //console.log(JSON.stringify(jda_Data));
56 jda_data_apiProducts = jda_Data.apiProducts;
57 //console.log(JSON.stringify(jda_data_apiProducts));
58 $.each(jda_data_apiProducts, function(index, data){
59 jda_apiProducts.push(data.replace(/ /g, ''));
60 });
61 //console.log('jda_apiProducts => ' + JSON.stringify(jda_apiProducts));
62
63 $.each(jda_apiProducts, function(index, data){
64 if (json_Product_Data_Array[data]) {
65 delete json_Product_Data_Array[data]._customAppFormDefinition;
66 //console.log('_customAppFormDefinition =>' + json_Product_Data_Array[data]._customAppFormDefinition);
67 delete json_Product_Data_Array[data].scopes;
68 jda_Data_Details.push(json_Product_Data_Array[data]);
69
70 let keyAvailable_hpidId = json_Product_Data_Array[data].hasOwnProperty("hpidId");
71 //console.log('keyAvailable_hpidId =>' + JSON.stringify(keyAvailable_hpidId));
72 if(keyAvailable_hpidId){
73 let hpidId = json_Product_Data_Array[data].hpidId;
74 if ( hpidId !== "undefined" || hpidId !== "") {
75 jda_data_HpIdEnabled = true;
76 } else {
77 //jda_data_HpIdEnabled = false;
78 }
79 // console.log('hpidId =>' + JSON.stringify(hpidId));
80 // console.log('jda_data_HpIdEnabled =>' + JSON.stringify(jda_data_HpIdEnabled));
81 }
82
83
84 if(jda_data_environments == ''){
85 //jda_data_environments.push(json_Product_Data_Array[data]._envCategory);
86 jda_data_environments = json_Product_Data_Array[data]._envCategory;
87 }
88 if(jda_data_bundling == ''){
89 //jda_data_bundling.push(json_Product_Data_Array[data].bundling);
90 jda_data_bundling = json_Product_Data_Array[data].bundling;
91 }
92
93 /* $.each(jda_data_environments, function(index, value){
94 if(value !== json_Product_Data_Array[data]._envCategory){
95 jda_data_environments.push(json_Product_Data_Array[data]._envCategory);
96 }
97 })
98 $.each(jda_data_bundling, function(index, value){
99 if(value !== json_Product_Data_Array[data].bundling){
100 jda_data_bundling.push(json_Product_Data_Array[data].bundling);
101 }
102 }) */
103 }
104 });
105 //console.log('jda_Data_Details =>' + JSON.stringify(jda_Data_Details));
106 //console.log('jda_data_environments =>' + JSON.stringify(jda_data_environments));
107 //console.log('jda_data_bundling =>' + JSON.stringify(jda_data_bundling));
108
109 /*
110 let attrData =[];
111 jda_Data['attributes'].forEach((item, index) => {
112 let obj = {};
113 obj[item.name] = item.value;
114 attrData.push(obj);
115 });
116 console.log(attrData);
117 let objAllinOne = Object.assign(...attrData);
118 //console.log(objAllinOne);
119 let jda_CAFF = JSON.parse(objAllinOne._customAppFormFields)
120 console.log(JSON.stringify(jda_CAFF));
121
122 //console.log(jda_CAFF);
123 // jda_CAFF['appAttributes'].forEach((item, index) => {
124 // let obj = {};
125 // obj[item.name] = item.value;
126 // attrData.push(obj);
127 // });
128 */
129 }
130 /******** For Add Product End *********************/
131
132 //let bundling = true;
133 $(document).ready(function () {
134 $.validator.addMethod("alphanumeric", function(value, element) {
135 return this.optional(element) || /^[\w.]+$/i.test(value);
136 }, "Letters, numbers, and underscores only please");
137
138 $.validator.addMethod("urlCheck", function(value, element) {
139 var regex = /^https:\/\/localhost((:|\/).*)?$|^https:\/\/127\.0\.0\.1((:|\/).*)?$|^(?:(?:https):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i;
140
141 return this.optional( element ) || regex.test(value);
142 }, "Please enter a valid URL without symbol #. Protocol is required ( https://) only.");
143
144 $('[data-toggle="tooltip"]').tooltip();
145 createFormValidate();
146 get_ProductByCategoryIndex(all_key_category, 'all', 'All', json_Category_Product_Data);
147
148 $(document).on('change', '#buList', function () {
149 let find_Child = $('#productByCategorieIndex').find("fieldset");
150 if (find_Child.length == 0) {
151 removeAllProductDetails();
152 }
153 let sltd_find_Child = $('#selectedProducts').find(".form-group");
154 if (find_Child.length == 0) {
155 removeAllSelectedProduct();
156 }
157 var selected_Value = $('#buList option:selected').attr('value');
158 var selected_Text = $('#buList option:selected').text();
159 var selected_IndexValue = $('#buList option:selected').data("indexvalue");
160 $('.select-box-inner').find('#productByCategorieIndex').empty();
161 if (selected_Value != '') {
162 resetAll();
163 get_ProductByCategoryIndex(selected_IndexValue, selected_Value, selected_Text, json_Category_Product_Data);
164 }
165 if(addProduct){
166 existed_ProductCompatibilityActivation();
167 }
168
169 setTimeout(function(){
170 $("#productsearch").trigger("keyup");
171 }, 200);
172 });
173
174 function delay(callback, ms) {
175 var timer = 0;
176 return function () {
177 var context = this,
178 args = arguments;
179 clearTimeout(timer);
180 timer = setTimeout(function () {
181 callback.apply(context, args);
182 }, ms || 0);
183 };
184 }
185
186 $(document).on(
187 "keyup",
188 "#productsearch",
189 delay(function (e) {
190 if (e.keyCode === 13) {
191 e.preventDefault();
192 return;
193 }
194
195 var selected_Value = $("#buList option:selected").attr("value");
196 var selected_Text = $("#buList option:selected").text();
197 var selected_IndexValue = $("#buList option:selected").data(
198 "indexvalue"
199 );
200
201 resetAll();
202
203 get_ProductByCategoryIndex(
204 selected_IndexValue,
205 selected_Value,
206 selected_Text,
207 json_Category_Product_Data
208 );
209
210 const s = $(this).val().toLowerCase();
211 if(s !== '')
212 {
213 $("#productByCategorieIndex label").each(function () {
214 $(this).parents("li").hide();
215
216 if ($(this).html().toLowerCase().indexOf(s) !== -1)
217 $(this).parents("li").show();
218 });
219 }
220 }, 500)
221 );
222
223
224 if(authZprodID!=''){
225 $(document).on('click', '#'+authZprodID+'[readonly="readonly"]', function (e) { e.preventDefault(); return false;});
226 $(document).on('click', '#clone_'+authZprodID+'[readonly="readonly"]', function (e) { e.preventDefault(); return false;});
227 }
228
229 $(document).on('click', '.custom-checkbox.pro-list label', function () {
230 var selected_Category = $('#buList option:selected').text();
231 let $this = $(this);
232 let parentEle = $(this).parent();
233 let isCheckbox = parentEle.find('input').is(':checkbox');
234 let isCheckboxChecked = parentEle.find('input[type=checkbox]').is(":checked");
235 let isReadOnly = parentEle.find('input').is('[readonly="readonly"]');
236 let proKey = parentEle.find('input').data('uniquekey');
237 let hpidValue = parentEle.find('input').data('hpid');
238 let bundlingValue = parentEle.find('input').data('bundling');
239 let extrnsysidntVal = parentEle.find('input').data('extrnsysidnt');
240 let hpidEnabled = parentEle.find('input').data('hpidenabled');
241 let _envCategory = parentEle.find('input').data('env');
242 let eleID = parentEle.find('input').attr('id');
243 let typeValue = parentEle.find('input').attr('type');
244 let nameValue = parentEle.find('input').attr('name');
245 let isDisabled = parentEle.find('input').prop('disabled');
246 let labelText = $(this).text();
247 // let approvalType = parentEle.find('input').data('approvaltype');
248 // console.log('approvalType => ' + approvalType);
249
250 if (!isDisabled) {
251 if (isCheckbox == true) {
252 if (isCheckbox == true && isCheckboxChecked == false) {
253 setTimeout(function () {
254 disable_Checkbox(hpidValue, bundlingValue, hpidEnabled, _envCategory, extrnsysidntVal);
255 }, 10);
256 get_ProdectDetailsByKey(proKey, selected_Category, eleID, hpidValue, bundlingValue, hpidEnabled, _envCategory,json_Product_Data_Array);
257 addSelectedProduct(proKey, eleID, typeValue, hpidValue, nameValue, labelText, bundlingValue, hpidEnabled, _envCategory);
258 $('[data-toggle="tooltip"]').tooltip();
259 setTimeout(function () {
260 if (bundlingValue == 'platform' && extrnsysidntVal=='Stratus' && eleID != authZprodID) {
261 removeProductDetailsByTarget($('#'+authZprodID).data('uniquekey'));removeAllSelectedProductByCheckbox(authZprodID);
262 $("#"+authZprodID).prop("checked", false).removeAttr('readonly');
263 setTimeout(function () {
264 $("label[for='"+authZprodID+"']").trigger('click');
265 setTimeout(function () { addReadOnly(authZprodID);}, 100);
266 }, 100);
267 }
268 }, 100);
269
270 } else {
271 if(!isReadOnly){
272 removeProductDetailsByTarget(proKey);
273 removeAllSelectedProductByCheckbox(eleID);
274 setTimeout(function () {
275 enable_Checkbox(hpidValue, bundlingValue, hpidEnabled, _envCategory);
276 if( bundlingValue == 'platform' && extrnsysidntVal=='Stratus'){
277 var chkbxCnt = $('.custom-checkbox.sltd-pro-list input[type=checkbox]:checked').not('#clone_'+authZprodID).length;
278 if(chkbxCnt<1) removeReadOnly(authZprodID);
279 }
280 }, 10);
281 }
282 }
283 }
284 noProductShowHide();
285 }
286 });
287 $(document).on('click', '.custom-checkbox.sltd-pro-list label', function () {
288 let parentEle = $(this).parent();
289 let Value = parentEle.find('input').attr('value');
290 let eleID = parentEle.find('input').attr('id');
291 let proKey = parentEle.find('input').data('uniquekey');
292 let isCheckbox = parentEle.find('input').is(':checkbox');
293 let isReadOnly = parentEle.find('input').is('[readonly="readonly"]');
294 let hpidValue = parentEle.find('input').data('hpid');
295 let bundlingValue = parentEle.find('input').data('bundling');
296 let hpidEnabled = parentEle.find('input').data('hpidenabled');
297 let _envCategory = parentEle.find('input').data('env');
298 if (isCheckbox == true && !isReadOnly) {
299 removeSltdProductUnchecked_List(eleID, Value);
300 removeProductDetailsByTarget(proKey);
301 enable_Checkbox(hpidValue, bundlingValue, hpidEnabled, _envCategory);
302 if( bundlingValue == 'platform'){
303 var chkbxCnt = $('.custom-checkbox.sltd-pro-list input[type=checkbox]:checked').not('#clone_'+authZprodID).length;
304 if(chkbxCnt<1) removeReadOnly(authZprodID);
305 }
306 }
307 });
308
309
310 $(document).on('click', '.remove-parent-fieldset', function () {
311 let inputCheckedTarget = $(this).data('tragetid');
312 let hpid_Value = $(this).closest('fieldset').data('hpid');
313 let bundlingValue = $(this).closest('fieldset').data('bundling');
314 let _envCategory = $(this).closest('fieldset').data('env');
315 let hpidEnabled = $(this).closest('fieldset').data('hpidenabled');
316 $.when($(this).closest('fieldset').remove())
317 .then(unchecked_Product(inputCheckedTarget))
318 .then(enable_Checkbox(hpid_Value, bundlingValue, hpidEnabled, _envCategory));
319 noProductShowHide();
320 if( bundlingValue == 'platform'){
321 var chkbxCnt = $('.custom-checkbox.sltd-pro-list input[type=checkbox]:checked').not('#clone_'+authZprodID).length;
322 if(chkbxCnt<1) removeReadOnly(authZprodID);
323 }
324 });
325
326 $(document).on('click', '.add-more', function () {
327 let _parentEle = $(this).closest('.input-allset');
328 let _parentEle_child = _parentEle.find('.input-set');
329 let _formGroupLength = _parentEle.find('.form-group').size();
330 let _LastInputEle = _parentEle.find('.form-group:last-child input');
331 let _firstInputEle = _parentEle.find('.form-group').eq(0).find('input');
332 let _labelValue = _parentEle.find('.form-group').eq(0).find('label.card-title').text();
333 let _inputIdValue = _parentEle.find('.form-group').eq(0).find('input').attr('id');
334 let _inputNameValue = _parentEle.find('.form-group').eq(0).find('input').attr('name');
335 let _inputTypeValue = _parentEle.find('.form-group').eq(0).find('input').attr('type');
336 let _inputPlaceholder = _parentEle.find('.form-group').eq(0).find('input').attr('placeholder');
337 let _limitValue = _parentEle.data('limit');
338 let _LastInputEleNameValue = _parentEle.find('.form-group:last-child input').attr('name');
339 //_formGroupLength = _parentEle.find('.form-group').size();
340 let hasClassError = _firstInputEle.hasClass('error');
341 let eleName_Value= JSON.stringify(_inputNameValue);
342 let ele_Value = $.trim(_LastInputEle.val());
343
344 switch (_inputTypeValue)
345 {
346 case 'text':
347 if(!hasClassError){
348 if(ele_Value !== ''){
349 addField(_formGroupLength, _limitValue, _parentEle, _labelValue, _inputNameValue, _inputIdValue, _inputTypeValue, _inputPlaceholder, _parentEle_child);
350 }else{
351 showCustomFieldError(_parentEle, _parentEle_child, _LastInputEleNameValue, _inputTypeValue);
352 }
353 }else{
354 // Do Nothing
355 }
356 break;
357 case 'url':
358 let urllValues = [];
359 _parentEle_child.find('.form-group').each(function(){
360 let userInputValue = $(this).find('input').val();
361 userInputValue = userInputValue.toLowerCase();
362 urllValues.push(userInputValue);
363 });
364 let urlDuplicatesValue = hasDuplicates(urllValues);
365 let validURL = /^(ftp|http|https):\/\/[^ "]+$/.test(String(ele_Value).toLowerCase());
366 if(!hasClassError){
367 if((ele_Value !== '') && (validURL == true)){
368 if(!urlDuplicatesValue){
369 addField(_formGroupLength, _limitValue, _parentEle, _labelValue, _inputNameValue, _inputIdValue, _inputTypeValue, _inputPlaceholder, _parentEle_child);
370 }else{
371 showCustomFieldError(_parentEle, _parentEle_child, _LastInputEleNameValue, _inputTypeValue, urlDuplicatesValue);
372 }
373 }else if(ele_Value == ''){
374 showCustomFieldError(_parentEle, _parentEle_child, _LastInputEleNameValue, _inputTypeValue);
375 }else{
376 // Do Nothing
377 }
378 }else{
379 // Do Nothing
380 }
381 break;
382 case 'email':
383 let emailValues = [];
384 _parentEle_child.find('.form-group').each(function(){
385 let userInputValue = $(this).find('input').val();
386 userInputValue = userInputValue.toLowerCase();
387 emailValues.push(userInputValue);
388 });
389 let emailDuplicatesValue = hasDuplicates(emailValues);
390 // console.log('emailDuplicatesValue => : '+ emailDuplicatesValue);
391 // console.log('emailValues => : '+ JSON.stringify(emailValues));
392 // console.log('hasDuplicates => : '+ hasDuplicates(emailValues));
393 let validEmil = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(ele_Value).toLowerCase());
394 if(!hasClassError){
395 if((ele_Value !== '') && (validEmil == true)){
396 if(!emailDuplicatesValue){
397 addField(_formGroupLength, _limitValue, _parentEle, _labelValue, _inputNameValue, _inputIdValue, _inputTypeValue, _inputPlaceholder, _parentEle_child);
398 }else{
399 showCustomFieldError(_parentEle, _parentEle_child, _LastInputEleNameValue, _inputTypeValue, emailDuplicatesValue);
400 }
401 }else if(ele_Value == ''){
402 showCustomFieldError(_parentEle, _parentEle_child, _LastInputEleNameValue, _inputTypeValue);
403 }else{
404 // Do Nothing
405 }
406 }else{
407 // Do Nothing
408 }
409 break;
410 case 'number':
411 let validNUMBER = /^.*[0-9].*$/.test(ele_Value);
412 if(!hasClassError){
413 if((ele_Value !== '') && (validNUMBER == true)){
414 addField(_formGroupLength, _limitValue, _parentEle, _labelValue, _inputNameValue, _inputIdValue, _inputTypeValue, _inputPlaceholder, _parentEle_child);
415 }else{
416 showCustomFieldError(_parentEle, _parentEle_child, _LastInputEleNameValue, _inputTypeValue);
417 }
418 }else{
419 // Do Nothing
420 }
421 break;
422 default:
423 // Do Nothing
424 }
425
426 });
427
428 /*
429 $(document).on('keyup', '.emailBlock .form-group:last-child input', function(event){
430 console.log($(this).val());
431 let emailValues = [];
432 let _parentEle = $(this).closest('.input-allset');
433 let _thisParent = $(this).closest('.form-group');
434 let _parentEle_child = _parentEle.find('.input-set');
435 let _LastInputEleNameValue = $(this).attr('name');
436 _parentEle_child.find('.form-group').each(function(){
437 let userInputValue = $(this).find('input').val();
438 emailValues.push(userInputValue);
439 });
440 let hasDuplicatesValue = hasDuplicates(emailValues);
441 console.log('hasDuplicatesValue => : '+ hasDuplicatesValue);
442 console.log('emailValues => : '+ JSON.stringify(emailValues));
443 if(hasDuplicatesValue){
444 _thisParent.append(
445 '<label class="error" style="display:inline-block;">This field is required and the value cannot be duplicated.</label>'
446 );
447 //$(this).val('');
448 $(this).addClass('error');
449 _thisParent.find('label.error').delay(3000).fadeOut(300, function(){
450 _thisParent.find('label.error').remove();
451 });
452 }else{
453 // Do Nothing
454 }
455 });
456 */
457
458 $(document).on('click', ".removeInputElement", function () {
459 var _parentEle = $(this).closest('.input-allset');
460 var _buttonSetEle = _parentEle.find('.button-set');
461 var _limitValue = _parentEle.data('limit');
462 if (_buttonSetEle.css('display') !== 'block') {
463 _buttonSetEle.show();
464 }
465 var nameMulti = $(this).closest('.form-group').find('input').attr('name');
466 var deleteSuffix = nameMulti.charAt(nameMulti.length - 1);
467 _parentEle.find(".addmoreSuffix").val(_parentEle.find(".addmoreSuffix").val().replace(" " + deleteSuffix, ""));
468 $(this).closest('.form-group').remove();
469 var _formGroupLength = _parentEle.find('.form-group').size();
470 if ((_formGroupLength > 1) || (_formGroupLength > 1 && _limitValue == "unlimited")) {
471 var removeButton = '';
472 removeButton += '<a href="javascript:;" class="removeInputElement"><span class="icon glyphicon glyphicon-remove" aria-hidden="true"></span> Remove</a>';
473 _parentEle.find('.form-group:last-child').append(removeButton);
474 }
475 });
476
477 $(document).on('click', '.cancel-button', function () {
478 if(addProduct){
479 var validator = $("#hp-my-apps-add-product-form").validate();
480 }
481 else
482 {
483 var validator = $("#hp-my-apps-create-form").validate();
484
485 }
486 validator.resetForm();
487 $('#formData').html('');
488 });
489 $(document).on('click', '#resetAllPro', function () {
490 resetAll();
491 productAccordionCloseAll();
492 });
493 $(document).on('click', '#ResetCancelButton', function () {
494 //resetAllProduct();
495 /*$("#dialog-confirm").html("Do you want to do the thing?");
496 $("#dialog-confirm").dialog({
497 resizable: false,
498 modal: true,
499 title: "Do the thing?",
500 height: 250,
501 width: 400,
502 buttons: {
503 "Yes": function() {
504 $(this).dialog('close');
505 alert("Yes, do the thing");
506 },
507 "No": function() {
508 $(this).dialog('close');
509 alert("Nope, don't do the thing");
510 }
511 }
512 });*/
513 });
514
515
516 $(document).on('click', '#edit-hp-my-apps-add-form-submit', function (e) {
517 createFormValidate();
518
519 });
520 $(document).on('click', '.dropdown-icon', function () {
521 let _parentEle = $(this).closest('.pro-list');
522 if (_parentEle.hasClass('open')) {
523 _parentEle.removeClass('open');
524 _parentEle.find('.pro-info').slideUp();
525 $(this).attr('title', 'Expand');
526 } else {
527 $('.pro-list').removeClass('open');
528 $('.pro-list').find('.pro-info').slideUp();
529 _parentEle.addClass('open');
530 _parentEle.find('.pro-info').slideDown();
531 $(this).attr('title', 'Collapse');
532 }
533 });
534 });
535 $(window).load(function () {
536 $('[data-toggle="tooltip"]').tooltip();
537 get_CategoryList();
538 $('#buList').val('all');
539 if(addProduct){
540 //console.log("jda True");
541 jsonDeveloperApp();
542 existed_ProductsList();
543 existed_ProductCompatibilityActivation();
544 }else{
545 //console.log("jda False");
546 }
547
548 });
549
550 function addReadOnly(eleID){
551 var fldsetID = $('#'+eleID).data('uniquekey');
552 $('#'+eleID).attr('readonly',true);
553 $('#clone_'+eleID).attr('readonly',true);
554 $("#"+fldsetID).find("[data-tragetid='"+eleID+"']").hide();
555 }
556 function removeReadOnly(eleID){
557 var fldsetID = $('#'+eleID).data('uniquekey');
558 $('#'+eleID).removeAttr('readonly');
559 $('#clone_'+eleID).removeAttr('readonly');
560 $("#"+fldsetID).find("[data-tragetid='"+eleID+"']").show();
561 }
562
563
564 function get_CategoryList() {
565 var categoryList = '', categoryNameList;
566 categoryNameList = json_Category_Product_Data.apiProduct;
567
568 categoryNameList.sort(function (a, b) {
569 var nameA = a.category.toUpperCase(); // ignore upper and lowercase
570 var nameB = b.category.toUpperCase(); // ignore upper and lowercase
571 if (nameA < nameB) {
572 return -1;
573 }
574 if (nameA > nameB) {
575 return 1;
576 }
577 // names must be equal
578 return 0;
579 });
580 $.each(categoryNameList, function (i, data) {
581 categoryList += '<option ' + 'value=' + data.category.toLowerCase().replace(/ /g, '').replace(/,/g, '').trim() + ' ' + 'data-indexValue=' + i + '>';
582 categoryList += data.category.replace(/,/g, '');
583 categoryList += '</option>';
584 });
585 $('#buList').append(categoryList);
586 }
587
588 function get_ProductByCategoryIndex(indexValue, categoryName, selected_Text, json_Category_Product_Data) {
589 let _html = '';
590 let is_HPIDProduct, hpidEnabled;
591 let productlist = 'hp_my_apps_add_form_product_list[]';
592 let keyAvailable = json_Category_Product_Data.apiProduct[indexValue].hasOwnProperty("products");
593 if (keyAvailable == true) {
594 let objByIndex = json_Category_Product_Data.apiProduct[indexValue].products;
595 let objByIndexLength = objByIndex.length;
596 //console.log('objByIndexLength => '+ objByIndexLength);
597 objByIndex.sort(function (a, b) {
598 var nameA = a.proName.toUpperCase(); // ignore upper and lowercase
599 var nameB = b.proName.toUpperCase(); // ignore upper and lowercase
600 if (nameA < nameB) {
601 return -1;
602 }
603 if (nameA > nameB) {
604 return 1;
605 }
606 return 0;
607 });
608 _html += '<p class="pro-count">('+objByIndexLength+')</p><p class="pro-error"><label for='+productlist+ ' class="error">Please select one checkbox option.</label></p>';
609 if (typeof objByIndex != "undefined" && objByIndex != null && objByIndex.length != null && objByIndex.length > 0) {
610 _html += '<ul>';
611 $.each(objByIndex, function (i, data) {
612 //console.log('Product Category => '+ data.category);
613 //console.log('Product Data => '+ JSON.stringify(data));
614 let replaced_Data = data.proName.toLowerCase().replace(/ /g, '').replace(/["'\(\)]/g, "").replace(/-/g, '').trim();
615 if (typeof data.is_HPIDProduct === "undefined") {
616 is_HPIDProduct = false;
617 } else {
618 is_HPIDProduct = true;
619 }
620 if (typeof data.hpidenabled === "undefined") {
621 hpidEnabled = false;
622 } else {
623 hpidEnabled = data.hpidenabled;
624 }
625
626 _html += "<li class='custom-checkbox pro-list'>";
627 _html += '<a href="javascript:;" title="Expand" class="dropdown-icon"></a>';
628 _html += '<input ' +
629 ' id=' + replaced_Data+'_'+data.unique_key + ' ' +
630 'name=' + productlist + ' ' +
631 'value=' + JSON.stringify(data.name) + ' ' +
632 'data-uniquekey=' + data.unique_key + ' ' +
633 'data-hpid=' + is_HPIDProduct + ' ' +
634 'data-approvaltype=' + data.approvalType + ' ' +
635 'data-env=' + (typeof data._envCategory == "undefined" ? "undefined" : data._envCategory.toLowerCase());
636 if ((data._envCategory == 'undefined') || (typeof data._envCategory == "undefined")) {
637 _html += ' disabled="disabled"';
638 } else {
639
640 }
641 if (data.bundling == undefined) {
642 _html += ' data-bundling="No"';
643 } else {
644 _html += ' data-bundling=' + data.bundling;
645 }
646 if ((data.externalProvisioningSystem == undefined) || (typeof data.externalProvisioningSystem == "undefined")) {
647 _html += ' data-extrnsysidnt="NONE"';
648 } else {
649 _html += ' data-extrnsysidnt=' + data.externalProvisioningSystem;
650 }
651 if (hpidEnabled) {
652 _html += ' data-hpidenabled=' + hpidEnabled;
653 } else {
654 _html += ' data-hpidenabled=' + hpidEnabled;
655 }
656 _html += ' type="checkbox" required >';
657 _html += '<label ' + 'for=' + replaced_Data+'_'+data.unique_key + '>';
658 _html += data.proName;
659 _html += '</label>';
660 // For Testing purpose, comment the code before Move on Git
661 /*
662 if (is_HPIDProduct) {
663 _html += '<span class="hp-id">(HPID Product)</span>';
664 }
665
666 if (hpidEnabled) {
667 _html += '<span class="hp-id-enabled">(HPID Enabled)</span>';
668 }
669 if (data.bundling == 'Yes') {
670 _html += '<span class="bundling-pro">(Bundling True)</span>';
671 }
672 _html += '<span class="pro-env">(' + data._envCategory + ')</span>';
673
674 if(data.category !== undefined){
675 _html += '<br/><span class="bundling-pro">Category : ' + data.category + '</span>';
676 }
677 */
678 // For Testing purpose, comment the code before Move on Git end
679 _html += '<ul class="pro-info"><li>';
680 if (data.bundling == undefined || data.bundling == 'No') {
681 _html += '<div class="has-note">'
682 _html += '<h5 class="note-title">Note :</h5>'
683 _html += '<p class="note-text">This API does not allow the use of combined credentials.</p>';
684 _html += '</div>';
685 }
686 if(data.category !== undefined){
687 _html += '<p>Category : ' + data.category + '</p>';
688 }else{
689 _html += '<p>Category : ' +' NA</p>';
690 }
691 if(data.description !== null){
692 _html += '<p>' + data.description + ' </p>';
693 }
694 if(data._apiProductDocNodeId != undefined)
695 _html += '<a href=' + '/node/' + data._apiProductDocNodeId + ' ' + 'class="pro-details" title="Product Documentation Details" target="_blank">Documentation</a>';
696 _html += '</li></ul>'
697
698 _html += "</li>";
699 });
700 _html += '</ul>';
701 } else {
702 _html += '<span class="alert-warning">Product Data Not Assign To This Category</span>';
703 }
704 } else {
705 _html += '<span class="alert-warning">Product Not Available</span>';
706 }
707 /* Get the products based on category */
708 $('#productByCategorieIndex').html(_html);
709 }
710
711
712 function unchecked_Product(inputTargetID) {
713 $('#productByCategorieIndex li').find("input[id=" + inputTargetID + "]").prop("checked", false);
714 $("#selectedProducts").find("input[id=" + 'clone_' + inputTargetID + "]").closest('.form-group').remove();
715
716 }
717 function removeAllProductDetails() {
718 $('#productDetails').find("fieldset").remove();
719 }
720 function removeAllSelectedProduct() {
721 $("#selectedProducts").find('.form-group').remove();
722 }
723 function removeAllSelectedProductByCheckbox(inputTargetID) {
724 $("#selectedProducts").find("input[id=" + 'clone_' + inputTargetID + "]").closest('.form-group').remove();
725 }
726 function removeSltdProductUnchecked_List(inputTargetID, Value) {
727 $('#productByCategorieIndex li').find("input[id=" + Value + "]").prop("checked", false);
728 $("#selectedProducts").find("input[id=" + inputTargetID + "]").closest('.form-group').remove();
729
730 }
731 function removeProductDetailsByTarget(traget_to_remove) {
732 $('#productDetails').find("#" + traget_to_remove).remove();
733 }
734
735 function get_ProdectDetailsByKey(product_Key, selected_Category, tragetid, is_hpid_true, bundlingValue, hpidEnabledValue, envCategory, json_Product_Data_Array) {
736
737 let detail_Obj, scopesByIndex, scopesResult, scopesClass, scopesAvailable, custom_FormData, is_customAppForm;
738 var prodHTML = '';
739 let custom_FormDataFields = [];
740 /* changed as per the json */
741 if (json_Product_Data_Array[product_Key]) {
742 detail_Obj = json_Product_Data_Array[product_Key];
743 //console.log('detail_Obj =>' + JSON.stringify(detail_Obj));
744 } else {
745 }
746
747 if (typeof detail_Obj.scopes === "undefined") {
748 } else {
749 scopesAvailable = detail_Obj.hasOwnProperty("scopes");
750 }
751 if (scopesAvailable == true) {
752 scopesByIndex = detail_Obj.scopes;
753 scopesResult = (typeof scopesByIndex != "undefined" && scopesByIndex != null && scopesByIndex.length != null && scopesByIndex.length > 0);
754 scopesClass = scopesResult ? 'has-scopes' : 'no-scopes';
755 } else {
756 }
757 if (typeof detail_Obj.scopes_description_details === "undefined") {
758 scopesDescriptionAvailable=false;
759 } else {
760 scopesDescriptionDetails = detail_Obj.scopes_description_details;
761 scopesDescriptionAvailable=true;
762
763 }
764
765 /**************** Custom form integration from JSON data ****************/
766 if (typeof detail_Obj._customAppFormDefinition === "undefined" || detail_Obj._customAppFormDefinition === 'null' ) {
767 is_customAppForm = false;
768 } else {
769 is_customAppForm = true;
770 custom_FormData = JSON.parse(detail_Obj._customAppFormDefinition);
771 // console.log(JSON.stringify(custom_FormDataFields));
772 custom_FormDataFields = custom_FormData.fields
773 custom_FormDataFields.sort(function (a, b) {
774 return a.weight - b.weight;
775 });
776 }
777 //console.log(JSON.stringify(custom_FormDataFields));
778
779 prodHTML += '<fieldset ' + 'class=' + scopesClass + ' id=' + product_Key + ' data-hpid=' + is_hpid_true + ' data-bundling=' + bundlingValue + ' data-env=' + envCategory + ' data-hpidenabled=' + hpidEnabledValue + ' >';
780 prodHTML += '<input type="hidden" id="apiProduct" name="apiProduct" value=' + product_Key + ' >';
781 prodHTML += '<div class="card form-card">';
782 prodHTML += '<div class="card-header">' + detail_Obj.displayName + '<a href="javascript:;" class="remove-parent-fieldset"' + ' ' + 'data-tragetid=' + tragetid + '>Close</a></div>';
783 if ((hpidEnabledValue) || (bundlingValue == 'No') || (bundlingValue == 'Yes')) {
784 prodHTML += '<div class="has-note"><ul class="note-list">';
785 prodHTML += '<h5 class="note-title">Please Note :</h5>';
786 prodHTML += '<li class="note-text">';
787 if ((envCategory == 'production')) {
788 prodHTML += '<p>You have selected a product which is deployed to a <span>PRODUCTION</span> environment and cannot be combined with products deployed to a NON-PRODUCTION environment.</p>';
789 }
790 if ((envCategory == 'other')) {
791 prodHTML += '<p>You have selected a product which is deployed to a <span>NON-PRODUCTION</span> environment and cannot be combined with products deployed to a PRODUCTION environment.</p>';
792 }
793 if (bundlingValue == 'No') {
794 prodHTML += '<p>You have selected a product which cannot be combined with any other.</p>';
795 }
796 if (hpidEnabledValue) {
797 prodHTML += '<p>You have selected an HPID-enabled product which cannot be combined with another HPID-enabled product.</p>';
798 }
799
800
801 prodHTML += '</li>';
802 prodHTML += '</ul></div>';
803 }
804 if ((bundlingValue == 'platform') && detail_Obj.externalProvisioningSystem=='Stratus' && tragetid==authZprodID) {
805 prodHTML += '<div class="has-note"><ul class="note-list">';
806 prodHTML += '<h5 class="note-title">Please Note :</h5>';
807 prodHTML += '<li class="note-text">';
808 prodHTML += '<p>You have selected a Stratus Platform product which depends on the Stratus AuthZ product. Please provide the necessary configuration information for Stratus AuthZ to create your app.</p>';
809 prodHTML += '</li>';
810 prodHTML += '</ul></div>';
811 }
812 prodHTML += '<div class="card-body">';
813 prodHTML += '<ul class="content-list"><li>';
814 if(detail_Obj.category !== undefined){
815 prodHTML += '<h5 class="card-title">Category :</h5>';
816 prodHTML += '<p class="card-text">' + detail_Obj.category + '</p>';
817 }else{
818 prodHTML += '<h5 class="card-title">Category :</h5>';
819 prodHTML += '<p class="card-text">' + ' NA</p>';
820 }
821 if(detail_Obj.description !== null){
822 prodHTML += '</li><li><h5 class="card-title">Description :</h5>';
823 prodHTML += '<p class="card-text">' + detail_Obj.description + '</p>';
824 }else{
825 prodHTML += '</li><li><h5 class="card-title">Description :</h5>';
826 prodHTML += '<p class="card-text">' + ' NA</p>';
827 }
828 prodHTML += '</li><li><h5 class="card-title"> </h5>';
829 if(detail_Obj._apiProductDocNodeId != undefined)
830 prodHTML += '<p class="card-text"><a href=' + '/node/' + detail_Obj._apiProductDocNodeId + ' ' + 'class="pro-details" title="Product Details" target="_blank">API Product doc</a></p>';
831 prodHTML += '</li></ul>';
832 if (scopesAvailable == true) {
833 if (scopesResult == true) {
834 prodHTML += '<div class="card-form-body">';
835 prodHTML += '<div class="if-product-scopes" id="product-scopes">';
836 prodHTML += '<p class="scopes-title">Select Product Scopes :<em>*</em>';
837 prodHTML += '<br><label for=scopes_'+product_Key+'[]' + ' ' + ' class="error" id="pro_scope">Please select at least one Scope.</label>';
838 prodHTML += '</p>';
839 $.each(scopesByIndex, function (index, value) {
840 if (value !== '') {
841 prodHTML += '<div class="form-group scopes-checkbox-list">';
842 prodHTML += '<div class="custom-checkbox">';
843 prodHTML += '<input class="scopes-checkbox" type="checkbox"' + ' value=' + JSON.stringify(value) +
844 ' id=scopes_' + product_Key.toLowerCase().replace(/ /g, '').replace(/-/g, '_') + '_' + value.toLowerCase().replace(/ /g, '') +
845 ' name=scopes_' + product_Key+ '[]' + ' required/>';
846 labelValue='';
847 if(scopesDescriptionAvailable && scopesDescriptionDetails[value] != undefined)
848 {
849 labelValue='<div class="scopes-description">'+scopesDescriptionDetails[value]+ '</div>';
850 }
851 prodHTML += '<label for=scopes_' + product_Key.toLowerCase().replace(/ /g, '').replace(/-/g, '_') + '_' + value.toLowerCase().replace(/ /g, '') + ' >';
852 prodHTML += value +labelValue+'</label>';
853 prodHTML += '</div></div>';
854 } else {
855 // Do Nothing
856 }
857 })
858 prodHTML += '</div></div>';
859 } else {
860 // Do Nothing.
861 }
862 } else {
863 // Do Nothing.
864 }
865 if (is_customAppForm) {
866 prodHTML += '<div class="card custom-form-card">';
867 prodHTML += '<div class="card-header">' + detail_Obj.displayName + ' Additional Information form custom form definitions</div>';
868 prodHTML += '<div class="card-body">';
869 $.each(custom_FormDataFields, function (i, data) {
870 //console.log(data);
871 if (data.type === 'radio') {
872 let required;
873 prodHTML += '<label class="card-title">' + data.label;
874 prodHTML += '</label>';
875 if (data.required === "TRUE") {
876 required = true;
877 prodHTML += '<em>*</em>';
878 }else{
879 required = false;
880 }
881 let dataID = data.id.replace(/ /g, '');
882 prodHTML += '<div class="help-block">' + data.help_text + '</div><p><label for=' + '"' + product_Key + '_unique_' + dataID + '"' + 'class="error">Please select one radio option.</label></p>';
883 if (typeof data.options === "undefined") {
884 // Do Nothing.
885 } else if (typeof data.options != "undefined" && data.options != null && data.options.length != null && data.options.length > 0) {
886 prodHTML += '<ul>';
887 $.each(data.options, function (i, data) {
888 prodHTML += "<li class='custom-checkbox'>";
889 prodHTML += '<input type="radio"' + 'name=' + product_Key + '_unique_' + dataID + ' ' +
890 'value=' + JSON.stringify(data.optionKey) + ' ';
891 if (isNaN(data.optionKey)) {
892 prodHTML += 'id=' + product_Key+'_unique_'+dataID+data.optionKey.replace(/ /g, '').trim() + ' ';
893 } else {
894 prodHTML += 'id=' + product_Key.toLowerCase().replace(/ /g, '')+'_unique_'+dataID+data.optionKey + ' ';
895 }
896 if (required) {
897 prodHTML += 'required';
898 }
899 prodHTML += ' />';
900 prodHTML += '<label ';
901 if (isNaN(data.optionKey)) {
902 prodHTML += 'for=' + product_Key+'_unique_'+dataID+data.optionKey.replace(/ /g, '').trim() + '>';
903 } else {
904 prodHTML += 'for='+product_Key.toLowerCase().replace(/ /g, '')+'_unique_'+dataID+data.optionKey+' >';
905 }
906 prodHTML += data.optionValue.replace(/-/g, '').trim();
907 prodHTML += '</label>';
908 prodHTML += "</li>";
909 })
910 prodHTML += '</ul>';
911 } else {
912 // Do Nothing.
913 }
914 }
915 if (data.type === 'select') {
916 let required;
917 prodHTML += '<div class="selectBox">';
918 prodHTML += '<label class="card-title">' + data.label;
919 prodHTML += '</label>';
920 if (data.required === "TRUE") {
921 required = true;
922 prodHTML += '<em>*</em>';
923 }else{
924 required = false;
925 }
926 let dataID = data.id.replace(/ /g, '');
927 prodHTML += '<p><label for=' + '"' + product_Key + '_unique_' + dataID + '"' + 'class="error">Please select one checkbox option.</label></p>';
928 if (typeof data.options === "undefined") {
929 // Do Nothing.
930 } else if (typeof data.options != "undefined" && data.options != null && data.options.length != null && data.options.length > 0) {
931 prodHTML += '<select id="mySelect" class="addFormSelect form-control" name=' + product_Key + '_unique_'+dataID+' '+
932 'data-toggle="tooltip" data-placement="top" title='+JSON.stringify(data.help_text)+ ' ';
933 if (required) {
934 prodHTML += 'required';
935 }
936 prodHTML += '>';
937 prodHTML += '<option value="" selected>Please select one</option>';
938 $.each(data.options, function (i, data) {
939 prodHTML += '<option value=' + JSON.stringify(data.optionKey) + '>';
940 prodHTML += data.optionValue;
941 prodHTML += '</option>';
942 })
943 prodHTML += '</select>';
944 } else {
945 // Do Nothing.
946 }
947 prodHTML += '</div>';
948 }
949 if (data.type === 'checkboxes') {
950 let required;
951 prodHTML += '<label class="card-title">' + data.label;
952 prodHTML += '</label>';
953 if (data.required === "TRUE") {
954 required = true;
955 prodHTML += '<em>*</em>';
956 }else{
957 required = false;
958 }
959 let dataID = data.id.replace(/ /g, '');
960 prodHTML += '<p><label for='+product_Key+'_unique_'+dataID+'[]' + ' class="error">Please select one checkbox option.</label></p>';
961 if (typeof data.options === "undefined") {
962 // Do Nothing.
963 } else if (typeof data.options != "undefined" && data.options != null && data.options.length != null && data.options.length > 0) {
964 prodHTML += '<ul>';
965 $.each(data.options, function (i, data) {
966 prodHTML += "<li class='custom-checkbox'>";
967 prodHTML += '<input type="checkbox"' + 'id=' + product_Key+'_unique_'+dataID+data.optionKey.replace(/ /g, '').trim() + ' ' +
968 'name=' + product_Key + '_unique_' + dataID + '[] ' +
969 'value=' + JSON.stringify(data.optionKey) + ' ';
970 if (required) {
971 prodHTML += 'required';
972 }
973 prodHTML += '>';
974 prodHTML += '<label ' + 'for=' + product_Key+'_unique_'+dataID+data.optionKey.replace(/ /g, '').trim() + '>';
975 prodHTML += data.optionValue;
976 prodHTML += '</label>';
977 prodHTML += "</li>";
978 })
979 prodHTML += '</ul>';
980 } else {
981 // Do Nothing.
982 }
983 }
984 if (data.type == 'textbox' || data.type == 'email' || data.type == 'url' || data.type == 'number' || data.type == 'date') {
985 let required;
986 let dataID = data.id.replace(/ /g, '');
987 if (data.id == "redirectUrl") {
988 prodHTML += '<div class="card custom-form-card">';
989 prodHTML += '<div class="card-header">Redirect URLs</div>';
990 prodHTML += '<div class="card-body">';
991 }
992 prodHTML += '<div';
993 if (data.limit > 1 || data.limit == "unlimited") {
994 prodHTML += ' class="input-allset add-more-parent '+data.type+'Block" ';
995 } else {
996 prodHTML += ' class="input-allset" ';
997 }
998 prodHTML += ' data-limit=' + data.limit+' >';
999 prodHTML += '<div class="input-set" data-required=' + data.required + '>';
1000 prodHTML += '<div class="form-group">';
1001 prodHTML += '<label class="card-title" for=' + '"' + product_Key + '_unique_' + dataID + '"' + '>' + data.label;
1002 prodHTML += '</label>';
1003
1004 if (data.required === "TRUE") {
1005 required = true;
1006 prodHTML += '<em>*</em>';
1007 }else{
1008 required = false;
1009 }
1010 //console.log(JSON.stringify(data.help_text));
1011 prodHTML += '<input ' + 'id=' + product_Key + '_unique_' + dataID + ' ' + 'class="form-control" data-toggle="tooltip" data-placement="top" title='+JSON.stringify(data.help_text)+ ' ' +
1012 'name=' + product_Key + '_unique_' + dataID + ' ';
1013 if (data.label.indexOf("Support email address") !== -1) {
1014 prodHTML += 'placeholder="Enter your email"';
1015 prodHTML += 'type="email"';
1016 } else if (data.label.indexOf("Support website") !== -1) {
1017 prodHTML += 'placeholder="Enter your website url"';
1018 prodHTML += 'type="url"';
1019 } else if (data.type == 'textbox') {
1020 prodHTML += 'placeholder="Enter your text"';
1021 prodHTML += 'type="text"';
1022 } else {
1023 prodHTML += 'placeholder="Enter your ' + data.type + '" ';
1024 prodHTML += 'type=' + data.type + ' ';
1025 }
1026 if (required) {
1027 prodHTML += 'required';
1028 }
1029 prodHTML += '>';
1030 prodHTML += '</div></div>';
1031 if (data.limit > 1 || data.limit == "unlimited") {
1032 prodHTML += '<div class="element-invisible"> <input class="addmoreSuffix" type="hidden" name="limit' + product_Key + '_unique_' + dataID + '" value="" ></div>';
1033 prodHTML += '<div class="button-set">';
1034 prodHTML += '<a href="javascript:;" class="btn add-more" value="Add more">+ Add More</a>';
1035 prodHTML += '</div>';
1036 } else {
1037 //Do Nothing
1038 }
1039 prodHTML += '</div>';
1040 if (data.id == "redirectUrl") {
1041 prodHTML += '</div></div>';
1042 }
1043 }
1044 });
1045 prodHTML += '</div>';
1046 prodHTML += '</div>';
1047 } else {
1048 //prodHTML += '<div>the _customAppFormDefinition property is not available...</div>';
1049 }
1050 prodHTML += '<ul class="content-list secret-key-expiry"><li>';
1051
1052 //prodHTML += '<h5 class="card-title">Secret Key Expiry :</h5>';
1053 //prodHTML += '<p class="card-text">You will be notified 20 days prior to Secret Key Expiry so that you can reset your API secret at your application details interface.</p>';
1054 prodHTML += '</li></ul>';
1055 prodHTML += '</div>';
1056 prodHTML += '</div></fieldset>';
1057 $('#productDetails').prepend(prodHTML);
1058 }
1059 function noProductShowHide() {
1060 let get_Fieldset = $('#productDetails').find('fieldset').size();
1061 if (get_Fieldset >= 1) {
1062 $('.no-product-selected').hide();
1063 } else {
1064 $('.no-product-selected').show();
1065 }
1066 }
1067
1068 function addSelectedProduct(product_Key, dataID, typeValue, hpidBoolean, nameValue, labelText, bundlingValue, hpidEnabledValue, envCategory) {
1069 if(!addProduct){
1070 $('.selected-title').show();
1071 }
1072 $('#resetAllPro').show();
1073 var _html = '';
1074 _html += '<div class="form-group custom-checkbox sltd-pro-list">';
1075 _html += '<input id="clone_' + dataID + '"' + ' name="clone_' + nameValue + '"' + ' value="' + dataID + '" data-uniquekey="' + product_Key + '" data-bundling="' + bundlingValue + '" ';
1076 if (hpidEnabledValue !== undefined) {
1077 _html += ' data-hpidenabled=' + hpidEnabledValue + ' ';
1078 }
1079 _html += ' data-hpid="' + hpidBoolean + '" type="' + typeValue + '" data-env="' + envCategory + '" checked>';
1080 _html += '<label for="clone_' + dataID + '"' + ' >' + labelText + '</label>';
1081 if (bundlingValue == 'No') {
1082 _html += '<div class="has-note">'
1083 _html += '<h5 class="note-title">Note :</h5>'
1084 _html += '<p class="note-text">You have selected a product which cannot be combined with any other.</p>';
1085 _html += '</div>';
1086 }
1087 if (hpidEnabledValue && bundlingValue == 'Yes') {
1088 _html += '<div class="has-note">'
1089 _html += '<h5 class="note-title">Note :</h5>'
1090 _html += '<p class="note-text">You have selected an HPID-enabled product which cannot be combined with another HPID-enabled product.</p>';
1091 _html += '</div>';
1092 }
1093 _html += '</div>';
1094 $("#selectedProducts").append(_html);
1095 }
1096
1097 function disable_Checkbox(hpidValue, bundling, hpidEnabledValue, envCatValue, extrnlsysidntfr) {
1098 var $filterCheckboxes = $('.custom-checkbox.pro-list input[type="checkbox"]').not(':checked');
1099 if (bundling == 'platform' && extrnlsysidntfr=='Stratus') {
1100 $filterCheckboxes.not('[data-extrnsysidnt="Stratus"]').each(function () {
1101 $(this).prop("disabled", true);
1102 });
1103 return true;
1104 }
1105 if (envCatValue == 'production') {
1106 $filterCheckboxes.filter('[data-env="other"]').each(function () {
1107 $(this).prop("disabled", true);
1108 });
1109 }
1110 if (envCatValue == 'other') {
1111 $filterCheckboxes.filter('[data-env="production"]').each(function () {
1112 $(this).prop("disabled", true);
1113 });
1114 }
1115 if (envCatValue == 'other' || envCatValue == 'production') {
1116 if (hpidEnabledValue) {
1117 $filterCheckboxes.filter('[data-hpidenabled="true"]').each(function () {
1118 $(this).prop("disabled", true);
1119 });
1120 }
1121 if (bundling == 'Yes') {
1122 $filterCheckboxes.not('[data-bundling="Yes"]').each(function () {
1123 $(this).prop("disabled", true);
1124 });
1125 }
1126
1127 }
1128 if ((envCatValue == 'other' || envCatValue == 'production') && (bundling == 'No')) {
1129 $filterCheckboxes.each(function () {
1130 $(this).prop("disabled", true);
1131 });
1132 }
1133 if (envCatValue == 'undefined') {
1134 }
1135 }
1136
1137 function enable_Checkbox(hpidValue, bundling, hpidEnabledValue, envCatValue) {
1138 let $filterCheckboxes = $('.custom-checkbox.pro-list input[type="checkbox"]');
1139 let checkbox_Checked_length = $filterCheckboxes.filter('input[type="checkbox"]:checked').size();
1140 if(!addProduct){
1141 if (checkbox_Checked_length <= 0) {
1142 $filterCheckboxes.each(function () {
1143 $(this).prop("checked", false);
1144 $(this).not('[data-env="undefined"]').prop("disabled", false);
1145 })
1146
1147 $('.selected-title').hide();
1148 $('#resetAllPro').hide();
1149 }
1150 }
1151 if ((envCatValue == 'production') && (bundling == 'Yes')) {
1152 if (hpidEnabledValue) {
1153 $filterCheckboxes.filter('[data-hpidenabled="true"]').each(function () {
1154 $(this).prop("checked", false);
1155 $(this).not('[data-bundling="No"]').not('[data-env="other"]').prop("disabled", false);
1156 });
1157 }
1158 }
1159 if ((envCatValue == 'other') && (bundling == 'Yes')) {
1160 if (hpidEnabledValue) {
1161 $filterCheckboxes.filter('[data-hpidenabled="true"]').each(function () {
1162 $(this).prop("checked", false);
1163 $(this).not('[data-bundling="No"]').not('[data-env="production"]').prop("disabled", false);
1164 });
1165 }
1166 }
1167
1168 if ((envCatValue == 'other' || envCatValue == 'production') && (bundling == 'No')) {
1169 $filterCheckboxes.each(function () {
1170 $(this).prop("checked", false);
1171 $(this).not('[data-env="undefined"]').prop("disabled", false);
1172 });
1173 }
1174 }
1175 function disable_Checkbox_EnvCatValue_Undefined() {
1176 let $filterCheckboxes = $('.custom-checkbox.pro-list input[type="checkbox"]');
1177 $filterCheckboxes.filter('[data-env="undefined"]').each(function () {
1178 $(this).prop("disabled", true);
1179 });
1180 }
1181
1182 function resetAllProduct() {
1183 if(!addProduct){
1184 $('.selected-title').hide();
1185 }
1186 $('#resetAllPro').hide();
1187 $('#commonField').find('input').val('');
1188 $('#productDetails').find("fieldset").remove();
1189 $("#selectedProducts").find('.form-group').remove();
1190 $('#productByCategorieIndex').empty();
1191 let $filterCheckboxes = $('.custom-checkbox.pro-list input[type="checkbox"]');
1192 $filterCheckboxes.each(function () {
1193 $(this).prop("checked", false);
1194 $(this).not('[data-env="undefined"]').prop("disabled", false);
1195 });
1196 $('form').trigger("reset");;
1197 $("html, body").animate({scrollTop: 0}, 500);
1198 }
1199 function resetAll() {
1200 $("#selectedProducts").find('.form-group').remove();
1201 $('#productDetails').find("fieldset").remove();
1202 if(!addProduct){
1203 $('.selected-title').hide();
1204 }
1205 $('#resetAllPro').hide();
1206 let $filterCheckboxes = $('.custom-checkbox.pro-list input[type="checkbox"]');
1207 $filterCheckboxes.each(function () {
1208 $(this).prop("checked", false);
1209 $(this).not('[data-env="undefined"]').prop("disabled", false);
1210 })
1211 }
1212 function createFormValidate(){
1213 $validateFrom= $("#hp-my-apps-create-form");
1214 if(addProduct){
1215 $validateFrom= $("#hp-my-apps-add-product-form");
1216 }
1217 $validateFrom.validate({
1218 normalizer: function( value ) {
1219 return $.trim( value );
1220 },
1221 rules: {
1222 text:{
1223 required: true,
1224 alphanumeric: true
1225 },
1226 url:{
1227 url:true,
1228 },
1229 email:{
1230 required: true,
1231 email:true
1232 },
1233 number:{
1234 required: true,
1235 number:true,
1236 //pattern: /^[a-zA-Z'.\s]{1,40}$/
1237 pattern: /^[0-9]+$/
1238 },
1239 'hp_my_apps_add_form_product_list[]':{
1240 required: true,
1241 },
1242 hp_my_apps_add_form_app_display_name: {
1243 required: true,
1244 minlength: 4,
1245 maxlength: 60
1246 },
1247 hp_my_apps_add_form_app_unique_name: {
1248 required: true,
1249 minlength: 4,
1250 maxlength: 100 // must give extra space to concatenate the date time stamp to the display name
1251 },
1252 hp_my_apps_add_form_app_justification:{
1253 required: true,
1254 // minlength: 60,
1255 // maxlength: 255
1256 },
1257 hp_my_apps_add_form_app_redirect_url: {
1258 urlCheck : true
1259 },
1260 messages: {
1261 'hp_my_apps_add_form_product_list[]':{
1262 required: "Please select atleast one Product"
1263 },
1264 hp_my_apps_add_form_app_display_name: {
1265 required: "Please enter a valid App Name",
1266 minlength: "App Name must be atleast 4 characters long",
1267 maxlength: "App Name not more then 60 characters"
1268 },
1269 hp_my_apps_add_form_app_justification:{
1270 required: "Please enter a valid App Justification Content",
1271 // minlength: "App Name must be atleast 60 characters long",
1272 // maxlength: "App Name not more then 255 characters"
1273 },
1274 hp_my_apps_add_form_app_unique_name: {
1275 required: "Please enter a valid unique name",
1276 minlength: "App Name must be at least 4 characters long",
1277 maxlength: "App Name not more then 60 characters"
1278 },
1279 hp_my_apps_add_form_app_redirect_url: {
1280 required: "Please enter a valid URL. Protocol is required ( https://) only."
1281 }
1282 },
1283 submitHandler: function (form) {
1284 form.submit();
1285 }
1286 }
1287 });
1288 }
1289
1290 function productAccordionCloseAll(){
1291 let _parentEleAll = $('.pro-list');
1292 if (_parentEleAll.hasClass('open')) {
1293 _parentEleAll.removeClass('open');
1294 _parentEleAll.find('.pro-info').slideUp();
1295 $('.dropdown-icon').attr('title', 'Expand');
1296 }
1297 }
1298
1299 function addField(_formGroupLength, _limitValue, _parentEle, _labelValue, _inputNameValue, _inputIdValue, _inputTypeValue, _inputPlaceholder, _parentEle_child){
1300 if ((_formGroupLength < _limitValue && _formGroupLength != _limitValue) || (_limitValue == "unlimited")) {
1301 _parentEle.find(".addmoreSuffix").val(_parentEle.find(".addmoreSuffix").val() + " " + (_formGroupLength + 1));
1302 let urlHtml = '';
1303 urlHtml += '<div class="form-group">';
1304 urlHtml += '<label class="card-title" for="' + _inputIdValue + (_formGroupLength + 1) + '"' + '>' + _labelValue +' '+ (_formGroupLength+1)+':</label>';
1305 urlHtml += '<input class="form-control" id="' + _inputIdValue + (_formGroupLength + 1) + '"' +
1306 'name="' + _inputNameValue + (_formGroupLength + 1) + '"' + ' type="' + _inputTypeValue + '"' + ' placeholder=' +
1307 JSON.stringify(_inputPlaceholder) + ' />';
1308 urlHtml += '<a href="javascript:;" class="removeInputElement"><span class="icon glyphicon glyphicon-remove" aria-hidden="true"></span> Remove</a>';
1309 urlHtml += '</div>';
1310 if ((_formGroupLength < _limitValue) || (_limitValue == "unlimited")) {
1311 _parentEle.find('.removeInputElement').remove();
1312 }
1313 _parentEle_child.append(urlHtml);
1314 }
1315 var _formGroupLength2 = _parentEle.find('.form-group').size();
1316
1317 if (_formGroupLength2 == _limitValue) {
1318 _parentEle.find('.button-set').hide();
1319 }
1320 }
1321
1322 function showCustomFieldError(_parentEle, _parentEle_child, _LastInputEleNameValue, _inputTypeValue, DuplicatesValue){
1323 _parentEle.find('.form-group:last-child input[name='+_LastInputEleNameValue+']').focus();
1324 if(DuplicatesValue){
1325 _parentEle_child.find('.form-group:last-child').append(
1326 '<label class="error" style="display:inline-block;">This field is required and the value cannot be duplicated.</label>'
1327 );
1328 _parentEle.find('.form-group:last-child input[name='+_LastInputEleNameValue+']').val('');
1329 }else{
1330 let _getElError = _parentEle_child.find('.form-group:last-child').find('label.error');
1331 let _elError_isVisiable = _getElError.is(":visible");
1332 if(!_elError_isVisiable){
1333 _parentEle_child.find('.form-group:last-child').append(
1334 '<label class="error" style="display:inline-block;">This field is required.</label>'
1335 );
1336 }
1337 }
1338 _parentEle.find('input[name='+_LastInputEleNameValue+']').addClass('error');
1339 _parentEle_child.find('.form-group:last-child').find('label.error').delay(3000).fadeOut(300, function(){
1340 // if(_inputTypeValue == 'text'){
1341 // _parentEle.find('.form-group:last-child input[name='+_LastInputEleNameValue+']').removeClass('error');
1342 // }
1343 _parentEle.find('.form-group:last-child input[name='+_LastInputEleNameValue+']').removeClass('error');
1344 _parentEle.find('.form-group:last-child').find('label.error').remove();
1345 });
1346 }
1347
1348 function hasDuplicates(array) {
1349 return (new Set(array)).size !== array.length;
1350 }
1351
1352 function jsonDeveloperApp(){
1353 let attributes_Obj_Fields, attributes_Obj_Data, attr_Data_Availability;
1354 let html = "";
1355 html += '<div class="card form-card">';
1356 html += '<div class="card-body">';
1357 html += '<ul class="content-list first-block">';
1358 html += '<li><h5 class="card-title">App Name :</h5><p class="card-text">'+jda_Data.appDisplayName+'</p></li>';
1359 html += '<li><h5 class="card-title">Developer Redirect URL :</h5>';
1360 //console.log(jda_Data.callbackUrl);
1361 if(jda_Data.callbackUrl !== undefined && jda_Data.callbackUrl !== ''){
1362 html += '<p class="card-text">' + jda_Data.callbackUrl + '</p>';
1363 }else{
1364 html += '<p class="card-text">' +' NA</p>';
1365 }
1366 html += '</li>';
1367 html += '<li class="description"><h5 class="card-title">Description :</h5>';
1368 //console.log(jda_Data.justification);
1369 if(jda_Data.justification !== undefined && jda_Data.justification !== ''){
1370 html += '<p class="card-text">' + jda_Data.justification + '</p>';
1371 }else{
1372 html += '<p class="card-text">' +' NA</p>';
1373 }
1374 html += '</li>';
1375 html += '</ul>';
1376 html += '<ul class="content-list apiDataDetails">';
1377 html += '<li><h5 class="card-title">API Key :</h5><p class="card-text">' + jda_Data.apiKey + '</p></li>';
1378 html += '<li><h5 class="card-title">Key Issued :</h5><p class="card-text">' + jda_Data.clientidIssued + '</p></li>';
1379 html += '<li><h5 class="card-title">Key Expires :</h5><p class="card-text expires">' + jda_Data.secretExpires + '</p></li>';
1380 html += '</ul>';
1381 html += '</div>';
1382 html += '</div>';
1383 $.each(jda_Data_Details, function (i, data) {
1384 html += '<div class="card form-card extd_prod_Details">';
1385 html += '<div class="card-header">'+data.displayName+'</div>';
1386 html += '<div class="card-body">';
1387 html += '<ul class="content-list">';
1388 html += '<li>';
1389 html += '<h5 class="card-title">Category :</h5>';
1390 if(data.category !== undefined){
1391 html += '<p class="card-text">'+data.category+'</p>';
1392
1393 }else{
1394 html += '<p class="card-text"> NA</p>';
1395 }
1396 html += '</li>';
1397 html += '<li>';
1398 html += '<h5 class="card-title">Description :</h5>';
1399 if(data.description !== undefined){
1400 html += '<p class="card-text">'+data.description+'</p>';
1401
1402 }else{
1403 html += '<p class="card-text"> NA</p>';
1404 }
1405 html += '</li>';
1406 html += '</ul>';
1407 html += '</div>';
1408 });
1409
1410 $("#existedproducts").append(html);
1411 }
1412
1413 function existed_ProductsList(){
1414 let html = "";
1415 html += '<ul class="content-list">';
1416 $.each(jda_Data_Details, function (i, data) {
1417 if(data.displayName !== undefined){
1418 html += '<li class="pro-name">'+data.displayName+'</li>';
1419 }else{
1420 html += '<li class="pro-name"> NA</li>';
1421 }
1422 })
1423 html += '</ul>';
1424 $("#oldProducts").append(html);
1425 }
1426
1427 function existed_ProductCompatibilityActivation(){
1428 let $filterCheckboxes = $('.custom-checkbox.pro-list input[type="checkbox"]');
1429 var $filterCheckboxes_NotChecked = $('.custom-checkbox.pro-list input[type="checkbox"]').not(':checked');
1430
1431
1432 if (jda_data_bundling == 'platform') {
1433 $filterCheckboxes_NotChecked.not('[data-extrnsysidnt="Stratus"]').each(function () {
1434 $(this).prop("disabled", true);
1435 });
1436 }else{
1437 if (jda_data_environments == 'production') {
1438 $filterCheckboxes_NotChecked.filter('[data-env="other"]').each(function () {
1439 $(this).prop("disabled", true);
1440 });
1441 }
1442 if (jda_data_environments == 'other') {
1443 $filterCheckboxes_NotChecked.filter('[data-env="production"]').each(function () {
1444 $(this).prop("disabled", true);
1445 });
1446 }
1447 if (jda_data_environments == 'other' || jda_data_environments == 'production') {
1448 if (jda_data_HpIdEnabled) {
1449 $filterCheckboxes_NotChecked.filter('[data-hpidenabled="true"]').each(function () {
1450 $(this).prop("disabled", true);
1451 });
1452 }
1453 if (jda_data_bundling == 'Yes') {
1454 $filterCheckboxes_NotChecked.not('[data-bundling="Yes"]').each(function () {
1455 $(this).prop("disabled", true);
1456 });
1457 }
1458
1459 }
1460 if ((jda_data_environments == 'other' || jda_data_environments == 'production') && (jda_data_bundling == 'No')) {
1461 $filterCheckboxes_NotChecked.each(function () {
1462 $(this).prop("disabled", true);
1463 });
1464 }
1465 }
1466 $.each(jda_apiProducts, function(index, value){
1467 $filterCheckboxes.filter('[data-uniquekey="'+value+'"]').each(function () {
1468 $(this).prop("disabled", false);
1469 $(this).prop("checked", true);
1470 $(this).closest('.pro-list').addClass('oldSelectedProduct');
1471 });
1472 } );
1473
1474
1475 }
1476 }
1477};
1478
1479