· 6 years ago · Sep 13, 2019, 08:08 AM
1jQuery.sap.require("sap.m.MessageBox");
2jQuery.sap.require("sap.m.MessageToast");
3
4jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectTypesFactory' + m_urlVersion);
5jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectTypesService' + m_urlVersion);
6jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectSusageStatusFactory' + m_urlVersion);
7jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectFrequencyFactory' + m_urlVersion);
8jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectFactory' + m_urlVersion);
9jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectUOMFactory' + m_urlVersion);
10jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectAGGREGATIONFactory' + m_urlVersion);
11jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectPMOFactory' + m_urlVersion);
12jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectPKPrimaryInfoFactory' + m_urlVersion);
13jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectLegFactory' + m_urlVersion);
14jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectGetChildFactory' + m_urlVersion);
15jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectSolutionFactory' + m_urlVersion);
16jQuery.sap.require('com.tutorial.service.measureobject.MeasurementObjectFeatureFactory' + m_urlVersion);
17jQuery.sap.require("com.tutorial.util.Formatter" + m_urlVersion);
18
19var varPath;
20var packNameForMO;
21var contextID;
22var that;
23var extendedAttributesTableData;
24var userDefinedAttributes;
25var stereotypeAttributes;
26
27jQuery.ajax({
28 url: userUrl,
29 method: 'GET',
30 dataType: 'json',
31
32 success: function(user)
33 {
34 username = user.USER;
35 },
36 error: function(XHR, Status, Error)
37 {
38 var error = Error;
39 console.log(XHR.responseText);
40 username = "default";
41 }
42});
43
44sap.ui.controller("ui5_routing.AddMo2", {
45 //the method handleNavBack is triggered when the back button is pressed
46 handleNavBack : function(oEvent) {
47 this.resetField();
48 var router = sap.ui.core.UIComponent.getRouterFor(this);
49 if (varPath != undefined)
50 router.navTo("Detail", {
51 contextPath : varPath,
52 contextID : contextID
53 });
54 else
55 if (sap.ui.getCore().byId("iconTabBar1") == undefined)
56 router.navTo("main");
57 else {
58 router.navTo("main", {
59 query : {
60 tab : sap.ui.getCore().byId("iconTabBar1").getSelectedKey()
61 }
62 }, true);
63 }
64 var that = this;
65 var moprodService = com.tutorial.service.measureobject.MeasurementObjectPMOFactory.getInstance();
66 moprodService.loadModel({
67 endpointParam : varPath,
68 successFunc : function(moData, response) {
69 var oModelMo = new sap.ui.model.json.JSONModel();
70 oModelMo.setData(moData.results[0]);
71 that.getView().setModel(oModelMo);
72 oModelMo.updateBindings(true);
73
74 },
75 errorFunc : function() {
76 var msg = 'Unsuccessfully added';
77 sap.m.MessageToast.show(msg);
78 }
79 })
80 },
81
82 onInit : function() {
83
84 that = this;
85 this.router = sap.ui.core.UIComponent.getRouterFor(this);
86 console.log("Hi in add for MO --" + this._oRouter);
87 this.router.attachRoutePatternMatched(this._handleRouteMatched, this);
88 var model = new sap.ui.model.odata.v2.ODataModel(m_xsodata);
89 this.getView().setModel(model, "techs");
90 },
91 //the method _handleRouteMatched is triggered after navigation to this page (this is necessary for routing)
92 //_handleRouteMatched is a hook method for the router and will be called automatically by the framework, after the view is rendered
93 // in this method are binded the necessary models on the AddMo2 view
94 _handleRouteMatched : function(oEvent) {
95
96 var table = this.byId("addMoTable");
97
98 jQuery.ajax({
99 url : userUrl,
100 method : 'GET',
101 dataType : 'json',
102 success : function(user) {
103 username = user.USER;
104 console.log("owneeeeeeeeeer1" + username)
105 },
106 error : function(XHR, Status, Error) {
107 var error = Error;
108 console.log(XHR.responseText);
109 username = "default";
110 }
111 });
112
113 var oParam = oEvent.getParameter("name");
114 if (oParam !== "AddMo2") {
115 return;
116 }
117 var that = this;
118 varPath = oEvent.getParameter("arguments").contextPath;
119 contextID = oEvent.getParameter("arguments").contextID;
120
121 var oModel = new sap.ui.model.json.JSONModel();
122 oModel.setData({
123 enabledName : false,
124 enabledTech : false,
125 enabledDescription : false,
126 enabledLogic : false,
127 enabledFrequency : false,
128 enabledStereotype: false,
129 enabledMethod : false,
130 enabledUOM : false,
131 enabledAggregation : false,
132
133 });
134 this.getView().setModel(oModel, "typeMO");
135
136 console.log("Inside the Line Item " + varPath);
137 userDefinedAttributes = [];
138 if (varPath != undefined) {
139 var packageService = com.tutorial.service.measureobject.MeasurementObjectPKPrimaryInfoFactory.getInstance();
140
141 packageService.loadModel({
142 endpointParam : varPath,
143 successFunc : function(moData, response) {
144 packNameForMO = moData.results[0].NAME;
145 var productName = moData.results[0].PRODUCT_NAME;
146
147 sap.ui.getCore().byId("labelGlobalMO").setText("Measurement Object will be added to " + packNameForMO);
148 sap.ui.getCore().byId("productTextForSearchView").setText(productName);
149
150 },
151 errorFunc : function() {
152 console.log('error');
153 }
154 });
155
156 }
157
158 this.MOAssigments = {};
159
160 var oModelMoType = new sap.ui.model.json.JSONModel();
161 oModelMoType.setData({
162 MoTypes : [],
163 Uoms : [],
164 Aggregations : [],
165 Frequencies : [],
166 SusageStatuses : []
167 });
168
169 sap.ui.getCore().setModel(oModelMoType, 'model');
170
171 var motypesService = com.tutorial.service.measureobject.MeasurementObjectTypesFactory.getInstance();
172 var uomService = com.tutorial.service.measureobject.MeasurementObjectUOMFactory.getInstance();
173 var aggregationService = com.tutorial.service.measureobject.MeasurementObjectAGGREGATIONFactory.getInstance();
174 var frequency = com.tutorial.service.measureobject.MeasurementObjectFrequencyFactory.getInstance();
175 var susageStatus = com.tutorial.service.measureobject.MeasurementObjectSusageStatusFactory.getInstance();
176
177 frequency.loadModel({
178 successFunc : function(moData, response) {
179 sap.ui.getCore().getModel('model').getData().Frequencies = moData.results;
180 that.byId("listFrequency").setModel(sap.ui.getCore().getModel('model'));
181 sap.ui.getCore().getModel('model').updateBindings(true);
182 },
183 errorFunc : function() {
184
185 }
186 });
187 susageStatus.loadModel({
188 successFunc : function(moData, response) {
189 sap.ui.getCore().getModel('model').getData().SusageStatuses = moData.results;
190 that.byId("listStatus").setModel(sap.ui.getCore().getModel('model'));
191 sap.ui.getCore().getModel('model').updateBindings(true);
192 },
193 errorFunc : function() {
194
195 }
196 });
197 var oModel = new sap.ui.model.odata.ODataModel(m_xsodata, true);
198 var filters = [];
199 filters.push(new sap.ui.model.Filter("ID", sap.ui.model.FilterOperator.Contains, 'NEMO'));
200 var that = this;
201 oModel.read("/OBJTYPES", {
202 filters : filters,
203 success : function(oData, oResponse) {
204
205 sap.ui.getCore().getModel('model').getData().MoTypes = oData.results;
206 that.getView().byId('listMOType').setModel(sap.ui.getCore().getModel('model'));
207 that.getView().byId('listMOType').setSelectedItem(that.getView().byId('listMOType').getItems()[0]);
208 that.handleMotypeSelected();
209 }
210 });
211 // UOM
212 uomService.loadModel({
213 successFunc : function(moData, response) {
214 sap.ui.getCore().getModel('model').getData().Uoms = moData.results;
215 that.byId("listUOM").setModel(sap.ui.getCore().getModel('model'));
216 sap.ui.getCore().getModel('model').updateBindings(true);
217 },
218 errorFunc : function() {
219
220 }
221 });
222
223 aggregationService.loadModel({
224 successFunc : function(moData, response) {
225 sap.ui.getCore().getModel('model').getData().Aggregations = moData.results;
226 that.byId("listAGGREGATION").setModel(sap.ui.getCore().getModel('model'));
227 sap.ui.getCore().getModel('model').updateBindings(true);
228 },
229 errorFunc : function() {
230 }
231 });
232
233 this.MOAssigments2 = {
234 Product : null,
235 ProductID : '',
236 FeatureID : '',
237 Feature : null,
238 Solution : null,
239 SolutionID : ''
240 };
241
242 var oModelMo = new sap.ui.model.json.JSONModel();
243 oModelMo.setData({
244 Products : [],
245 Solutions : [],
246 Features : [],
247 });
248 sap.ui.getCore().setModel(oModelMo, 'pageModel');
249
250 var solutionService = com.tutorial.service.measureobject.MeasurementObjectSolutionFactory.getInstance();
251 var featureService = com.tutorial.service.measureobject.MeasurementObjectFeatureFactory.getInstance();
252
253
254 var oDataMOdel = new sap.ui.model.odata.ODataModel(m_xsodata);
255 oDataMOdel.read("/CV_NODE_PARENTSParameters(P_NODEID=\'" + varPath + "\')/Results/?$orderby=LEVEL", null, null, true, fSuccess, fError);
256 function fSuccess(oEvent) {
257
258 var parents = [];
259 parents = oEvent.results;
260 sap.ui.getCore().byId("PanelIdNavAdd").removeAllContentMiddle();
261 for ( var i in parents) {
262 if (i != 0) {
263 var breadcrumb = sap.ui.getCore().byId("PanelIdNavAdd").addContentMiddle(new sap.m.Text({
264 text : ">"
265
266 }).addStyleClass("textForArrow"))
267 }
268
269 var oLink = new sap.m.Button({
270 text : parents[i].NAME,
271 enabled : false
272
273 });
274 oLink.nodeid = parents[i].RESULT_NODE;
275 if (i == parents.length - 1)
276 oLink.addStyleClass("lastBreadcrumb");
277 var breadcrumb = sap.ui.getCore().byId("PanelIdNavAdd").addContentMiddle(oLink);
278 }
279 }
280 ;
281 function fError(oEvent) {
282 console.log("An error occured while reading Parents Data!")
283 }
284 ;
285
286 var oDataModelStereotypes = new sap.ui.model.odata.ODataModel(m_xsodata);
287 oDataModelStereotypes.read("/CL_STEREOTYPE_HIER_DETAILParameters" + "(IP_TYPE='" + 'MO' + "')/Results", null, null, true, fSuccessStereotypes, fErrorStereotypes);
288
289
290 function fSuccessStereotypes(oEvent) {
291
292 data = oEvent.results;
293 var listPopulator = that.byId("listStereotype");
294 listPopulator.destroyItems();
295 var listItem = new sap.m.StandardListItem({
296 title: "",
297 customData:[
298 new sap.ui.core.CustomData({
299 key:"KEY",
300 value: "valueeee"
301 }),
302 ]
303 })
304 listPopulator.addItem(listItem);
305
306 for(var item of data){
307
308 var listItem = new sap.m.StandardListItem({
309 title: item.PATH,
310 customData:[
311 new sap.ui.core.CustomData({
312 key:"KEY",
313 value: "valueeee"
314 }),
315 ]
316// press: that.onListItemPress
317
318 })
319
320
321 listPopulator.addItem(listItem);
322 }
323 that.MOAssigments.Stereotype = "";
324
325 };
326
327 function fErrorStereotypes(oEvent) {
328 console.log("An error occured while reading the data!")
329 };
330
331
332 },
333
334 handleStereotypeSelected : function(evt) {
335
336 var selectedItem = this.byId("listStereotype").getSelectedItem().getProperty("title");
337 var selectedID = this.byId("listStereotype").getSelectedItem().getTitle();
338 var moService = com.tutorial.service.measureobject.MeasurementObjectFactory.getInstance();
339
340 this.byId("inputStereotype").setValue(selectedItem);
341 this.byId("popoverStereotype").close();
342 sap.ui.getCore().byId("butonelSt").setIcon("sap-icon://cancel");
343 this.MOAssigments.Stereotype = selectedID;
344
345 var table = this.byId("addMoTable");
346 table.setVisible(true);
347
348 var stereoTypeList = evt.getParameters().listItem.mProperties.title;
349 var stereoTypeArray = stereoTypeList.split('/');
350 var stereoType = stereoTypeArray[stereoTypeArray.length - 1];
351
352 this.loadTableData(stereoType);
353
354 },
355
356 AddRecord: function(oEvent){
357
358 var that = this;
359
360 var oDialogAddRow = sap.ui.getCore().byId(this.createId('Dialog'));
361 var oDialogSaveButton = sap.ui.getCore().byId(this.createId('oDialogSaveButton'));
362 oDialogAddRow.setTitle("ADD A NEW RECORD");
363 var oLayout = new sap.ui.commons.layout.MatrixLayout({
364 columns: 2,
365 width: "100%"
366 });
367
368 var oFirstLabel= sap.ui.getCore().byId(this.createId('oFirstLabel'));
369 var oFirstTF = sap.ui.getCore().byId(this.createId('attrid'));
370 oFirstTF.setValue('');
371 oLayout.createRow(oFirstLabel, oFirstTF);
372
373 var oSecondLabel = sap.ui.getCore().byId(this.createId('oSecondLabel'));
374 var oSecondTF = sap.ui.getCore().byId(this.createId('valueid'));
375 oSecondTF.setValue('');
376 oLayout.createRow(oSecondLabel, oSecondTF);
377
378 oDialogAddRow.addContent(oLayout);
379 oDialogAddRow.open();
380
381 },
382
383 saveRecord: function(oEvent){
384
385 var that = this;
386 var attrTable = sap.ui.getCore().byId(this.createId('addMoTable'));
387 var oFirstTF = sap.ui.getCore().byId(this.createId('attrid'));
388 var oSecondTF = sap.ui.getCore().byId(this.createId('valueid'));
389 var attribute = oFirstTF.getValue();
390 var value = oSecondTF.getValue();
391 var existing = false;
392 attrTable.getItems().forEach(function(collListItem){
393 if(collListItem.getCells()[0].getText() == attribute){
394 existing = true;
395 }
396 })
397 if(attribute == "" || value == ""){
398 sap.m.MessageToast.show('Both values are mandatory!');
399 }
400 else if(attribute.indexOf(' ') > -1){
401 sap.m.MessageToast.show('Attribute name can not contain spaces');
402 }
403 else if(existing){
404 sap.m.MessageToast.show('Attribute allready exists');
405 }
406 else{
407 var columnListItem = new sap.m.ColumnListItem({
408
409 cells: [
410 new sap.m.Text({
411
412 text : attribute
413 }),
414 new sap.m.Input({
415
416 value : value,
417 width: "80%"
418 }),
419 new sap.m.Text({
420 text: username
421 })
422
423 ],
424
425 type: 'Active'
426 })
427
428 attrTable.addItem(columnListItem);
429 userDefinedAttributes.push({ DATATYPE: "String",
430 MANAGED_BY: username,
431 NAME: attribute,
432 VALUE: value});
433 sap.ui.getCore().byId(this.createId('Dialog')).close();
434 }
435 },
436
437 DeleteRecord: function(){
438 var that = this;
439 var attrTable = sap.ui.getCore().byId(this.createId('addMoTable'));
440 var toBeDeleted = attrTable.getSelectedItems();
441 toBeDeleted.forEach(function(attr){
442 if(attr.getCells()[2].getText() != "Stereotype"){
443 userDefinedAttributes = userDefinedAttributes.filter(toDelete => toDelete.NAME != attr.getCells()[0].getText() );
444
445 attrTable.removeItem(attr);
446 attr.destroy();
447 }
448 else{
449 sap.m.MessageToast.show('One or more attributes can not be deleted because they are managed by the stereotype');;
450 }
451 })
452 },
453
454 loadTableData: function (stereoType) {
455
456 var usageServicePath = "https://ifd.wdf.sap.corp/usag/morepository/MOREPOSITORY/Usage.xsodata";
457 var model = "/CL_ALL_ATTRIBUTES_FOR_STEREOTYPEParameters";
458 var viewPath = model + "(IP_STEREOTYPE_ID='" + stereoType + "')/Results";
459 var that = this;
460
461 $.ajax({
462 async: true,
463 url: usageServicePath + viewPath,
464 type: 'GET',
465 cache: false,
466 dataType: 'JSON',
467 success: function (data) {
468 var results = data.d.results;
469 if (results.length > 0) {
470
471 that.bindTable(results);
472
473 } else {
474 that.bindTable([]);
475 }
476 },
477 error: function () {
478 //trace some errors
479 }
480 });
481
482 },
483 bindTable: function (results) {
484
485 var table = this.getView().byId(this.createId("addMoTable"));
486 table.destroyItems();
487 that = this;
488 that.extendedAttributes = [];
489 for (var i = 0; i < results.length; i++) {
490 //to do -> put the correct fields
491 var attribute = results[i].NAME;
492 var description = results[i].DESCRIPTION;
493 var placeholder = results[i].DEFAULTVALUE;
494
495
496
497 that.extendedAttributes.push(results[i].NAME);
498
499 var columnListItem = new sap.m.ColumnListItem({
500 cells: [
501 new sap.m.Label({
502 id: "Text" + attribute,
503 text: attribute
504 }),
505 this.quickhelp(new sap.m.Input({
506 //todo --> map the input fields to the attribute or counter etc..
507 id: "Value" + attribute,
508 value: placeholder,
509 width: "80%"
510 }),description),
511 new sap.m.Text({
512 id: "Managed" + attribute,
513 text: "Stereotype"
514 })
515 ]
516 })
517
518 table.addItem(columnListItem);
519 }
520
521 for (var i = 0; i < userDefinedAttributes.length; i++) {
522 //to do -> put the correct fields
523 var attribute = userDefinedAttributes[i].NAME;
524 var value = userDefinedAttributes[i].VALUE;
525
526 var columnListItem = new sap.m.ColumnListItem({
527 cells: [
528 new sap.m.Label({
529 id: "Text" + attribute,
530 text: attribute
531 }),
532 new sap.m.Input({
533 //todo --> map the input fields to the attribute or counter etc..
534 id: "Value" + attribute,
535 value: value,
536 width: "80%"
537 }),
538 new sap.m.Text({
539 id: "Managed" + attribute,
540 text: "Stereotype"
541 })
542 ]
543 })
544
545 table.addItem(columnListItem);
546 }
547 },
548
549
550//the method filterFrequency is called when the mouse is put on the input(id "inputFrequency") of Measurement Frequency. At the mouse press the pop-up with possible entries appear (id "listFrequency").
551 filterFrequency : function() {
552
553 var searchValue = jQuery.trim(this.byId("inputFrequency").getValue());
554 var showSearch = (searchValue.length !== 0);
555
556 var binding = this.byId("listFrequency").getBinding("items");
557 if (showSearch && binding !== undefined) {
558 var filters = [];
559 filters.push(new sap.ui.model.Filter("NAME", sap.ui.model.FilterOperator.Contains, searchValue));
560 binding.filter(filters);
561 } else {
562 binding.filter(false);
563 }
564 },
565 //the method handleFrequencySelected is called when a value from the list displayed (id: "listFrequency") is selected
566 handleFrequencySelected : function(evt) {
567 var selectedItem = this.byId("listFrequency").getSelectedItem().getProperty("title");
568 var selectedID = this.byId("listFrequency").getSelectedItem().getTitle();
569 var moService = com.tutorial.service.measureobject.MeasurementObjectFactory.getInstance();
570
571 this.byId("inputFrequency").setValue(selectedItem);
572 this.byId("popoverFrequency").close();
573 sap.ui.getCore().byId("butonelSys").setIcon("sap-icon://cancel");
574 this.MOAssigments.Frequency = selectedID;
575
576 },
577
578 //the method handleStereotypeSelected is called when a value from the list displayed (id: "listStereotype") is selected
579 filterStereotype : function() {
580
581 var searchValue = jQuery.trim(this.byId("inputStereotype").getValue());
582 var showSearch = (searchValue.length !== 0);
583
584 var binding = this.byId("listStereotype").getBinding("items");
585 if (showSearch && binding !== undefined) {
586 var filters = [];
587 filters.push(new sap.ui.model.Filter("NAME", sap.ui.model.FilterOperator.Contains, searchValue));
588 binding.filter(filters);
589 } else {
590 binding.filter(false);
591 }
592 },
593
594
595 //the method filterStatus is called when the mouse is put on the input(id "inputStatus") of Measurement method. At the mouse press the pop-up with possible entries appear (id "listStatus").
596 filterStatus : function() {
597
598 var searchValue = jQuery.trim(this.byId("inputStatus").getValue());
599 var showSearch = (searchValue.length !== 0);
600
601 var binding = this.byId("listStatus").getBinding("items");
602 if (showSearch && binding !== undefined) {
603 var filters = [];
604 filters.push(new sap.ui.model.Filter("NAME", sap.ui.model.FilterOperator.Contains, searchValue)); // name
605
606 binding.filter(filters);
607 } else {
608 binding.filter(false);
609 }
610 },
611 //the method handleStatusSelected is called when a value from the list displayed (id: "listStatus") is selected
612 handleStatusSelected : function(evt) {
613 var selectedItem = this.byId("listStatus").getSelectedItem().getProperty("title");
614
615 var selectedID = this.byId("listStatus").getSelectedItem().getTitle();
616 var moService = com.tutorial.service.measureobject.MeasurementObjectFactory.getInstance();
617
618 this.byId("inputStatus").setValue(selectedItem);
619
620 this.byId("popoverStatus").close();
621 sap.ui.getCore().byId("butonelSysSusage").setIcon("sap-icon://cancel");
622 this.MOAssigments.Status = selectedID;
623
624 },
625 //the method filterMotype is called when the mouse is put on the input(id "inputMOType") of Measurement Object Type. At the mouse press the pop-up with possible entries appear (id "listMOType").
626 filterMotype : function() {
627
628 var searchValue = jQuery.trim(sap.ui.getCore().byId('inputMOType').getValue());
629 var showSearch = (searchValue.length !== 0);
630
631 var binding = this.byId("listMOType").getBinding("items");
632 if (showSearch && binding !== undefined) {
633 var filters = [];
634 filters.push(new sap.ui.model.Filter("NAME", sap.ui.model.FilterOperator.Contains, searchValue));
635 binding.filter(filters);
636 } else {
637 binding.filter(false);
638 }
639 },
640
641 //the method handleMotypeSelected is called when a value from the list displayed (id: "listMOType") is selected
642 handleMotypeSelected : function(evt) {
643 this.resetField();
644 var selectedItem = this.byId("listMOType").getSelectedItem().getProperty("title");
645 var selectedID = this.byId("listMOType").getSelectedItem().getTitle();
646 var moService = com.tutorial.service.measureobject.MeasurementObjectFactory.getInstance();
647 var that = this;
648 sap.ui.getCore().byId('inputMOType').setValue(selectedItem);
649 this.byId("popoverMOType").close();
650
651 this.MOAssigments.MotypeID = selectedID;
652 if (sap.ui.getCore().byId('inputMOType').getValue() == 'NEMO') {
653 sap.ui.getCore().byId('butonelSys').setIcon("sap-icon://arrow-down");
654 sap.ui.getCore().byId('butonelSt').setIcon("sap-icon://arrow-down");
655 sap.ui.getCore().byId('butonelSysSusage').setIcon("sap-icon://arrow-down");
656 sap.ui.getCore().byId('butonelSysUOM').setIcon("sap-icon://arrow-down");
657 sap.ui.getCore().byId('butonelSysAggregation').setIcon("sap-icon://arrow-down");
658 sap.ui.getCore().byId('technicalNameFieldIdMO').setShowValueHelp(false);
659 sap.ui.getCore().byId('butonelSys').setVisible(true);
660 sap.ui.getCore().byId('butonelSt').setVisible(true);
661 sap.ui.getCore().byId('butonelSysSusage').setVisible(true);
662 sap.ui.getCore().byId('butonelSysUOM').setVisible(true);
663 sap.ui.getCore().byId('butonelSysAggregation').setVisible(true);
664
665 var oModel = new sap.ui.model.json.JSONModel();
666 oModel.setData({
667 enabledName : true,
668 enabledTech : true,
669 enabledDescription : true,
670 enabledLogic : true,
671 enabledFrequency : true,
672 enabledStereotype: true,
673 enabledMethod : true,
674 enabledUOM : true,
675 enabledAggregation : true,
676 });
677 this.getView().setModel(oModel, "typeMO");
678 } else {
679 sap.ui.getCore().byId('butonelSys').setVisible(false);
680 sap.ui.getCore().byId('butonelSt').setVisible(false);
681 sap.ui.getCore().byId('butonelSysSusage').setVisible(false);
682 sap.ui.getCore().byId('butonelSysUOM').setVisible(false);
683 sap.ui.getCore().byId('butonelSysAggregation').setVisible(false);
684
685 sap.ui.getCore().byId('technicalNameFieldIdMO').setShowValueHelp(true)
686 var oModel = new sap.ui.model.json.JSONModel();
687 oModel.setData({
688 enabledName : false,
689 enabledTech : true,
690 enabledDescription : true,
691 enabledLogic : false,
692 enabledFrequency : false,
693 enabledStereotype : false,
694 enabledMethod : false,
695 enabledUOM : false,
696 enabledAggregation : false,
697 AGG : 'SUM',
698 FREQ : 'Monthly',
699 Stereotype: '',
700 UOM : 'Traffic'
701 });
702 this.MOAssigments.Frequency = 'Monthly';
703 this.MOAssigments.Stereotype = 'Custom';
704 this.MOAssigments.UOM = 'Traffic';
705 this.MOAssigments.AGGREGATION = 'SUM';
706 this.getView().setModel(oModel, "typeMO");
707 }
708
709 },
710
711 //the method filterUOM is called when the mouse is put on the input(id "inputUOM") of Unit of Measure. At the mouse press the pop-up with possible entries appear (id "listUOM").
712 filterUOM : function() {
713
714 var searchValue = jQuery.trim(this.byId("inputUOM").getValue());
715 var showSearch = (searchValue.length !== 0);
716
717 var binding = this.byId("listUOM").getBinding("items");
718 if (showSearch && binding !== undefined) {
719 var filters = [];
720 filters.push(new sap.ui.model.Filter("NAME", sap.ui.model.FilterOperator.Contains, searchValue));
721 binding.filter(filters);
722 } else {
723 binding.filter(false);
724 }
725 },
726 //the method handleUOMSelected is called when a value from the list displayed (id: "listUOM") is selected
727 handleUOMSelected : function(evt) {
728 var selectedItem = this.byId("listUOM").getSelectedItem().getProperty("title");
729 var selectedID = this.byId("listUOM").getSelectedItem().getTitle();
730 var moService = com.tutorial.service.measureobject.MeasurementObjectFactory.getInstance();
731 this.byId("inputUOM").setValue(selectedItem);
732 this.byId("popoverUOM").close();
733 sap.ui.getCore().byId("butonelSysUOM").setIcon("sap-icon://cancel");
734 this.MOAssigments.UOM = selectedItem;
735 },
736
737 //the method filterAGGREGATION is called when the mouse is put on the input(id "inputAGGREGATION") of Aggregation. At the mouse press the pop-up with possible entries appear (id "listAGGREGATION").
738 filterAGGREGATION : function() {
739
740 var searchValue = jQuery.trim(this.byId("inputAGGREGATION").getValue());
741 var showSearch = (searchValue.length !== 0);
742
743 var binding = this.byId("listAGGREGATION").getBinding("items");
744 if (showSearch && binding !== undefined) {
745 var filters = [];
746 filters.push(new sap.ui.model.Filter("NAME", sap.ui.model.FilterOperator.Contains, searchValue));
747 binding.filter(filters);
748 } else {
749 binding.filter(false);
750 }
751 },
752 //the method handleAGGREGATIONSelected is called when a value from the list displayed (id: "listAGGREGATION") is selected
753 handleAGGREGATIONSelected : function(evt) {
754 var selectedItem = this.byId("listAGGREGATION").getSelectedItem().getProperty("title");
755 var selectedID = this.byId("listAGGREGATION").getSelectedItem().getTitle();
756 var moService = com.tutorial.service.measureobject.MeasurementObjectFactory.getInstance();
757 this.byId("inputAGGREGATION").setValue(selectedItem);
758 this.byId("popoverAGGREGATION").close();
759 sap.ui.getCore().byId("butonelSysAggregation").setIcon("sap-icon://cancel");
760 this.MOAssigments.AGGREGATION = selectedItem;
761 },
762
763 //the method generateKey is triggered from addMo method to generate a new key for the new package that will be added
764 generateKey : function() {
765 var key = Math.floor((Math.random() * 10000) + 1);
766
767 return key.toString();
768 },
769 checkEmptyFields : function() {
770 if (sap.ui.getCore().byId('inputMOType').getValue() == "NEMO") {
771 if ((!sap.ui.getCore().byId('technicalNameFieldIdMO').getValue()) || (!sap.ui.getCore().byId('keyTextFieldId').getValue()) || (!sap.ui.getCore().byId('inputMOType').getValue())) {
772 // check that inputs are not empty
773 if (!sap.ui.getCore().byId('technicalNameFieldIdMO').getValue())
774 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("Error");
775 if (!sap.ui.getCore().byId('keyTextFieldId').getValue())
776 sap.ui.getCore().byId('keyTextFieldId').setValueState("Error");
777 if (!sap.ui.getCore().byId('inputMOType').getValue())
778 sap.ui.getCore().byId('inputMOType').setValueState("Error");
779 var msg = 'Please fill the mandatory fields!';
780 sap.m.MessageToast.show(msg);
781 return false;
782 }
783 return true;
784 } else {
785 if ((!sap.ui.getCore().byId('technicalNameFieldIdMO').getValue()) || (!sap.ui.getCore().byId('keyTextFieldId').getValue()) || (!sap.ui.getCore().byId('inputMOType').getValue())) {
786 // check that inputs are not empty
787 if (!sap.ui.getCore().byId('technicalNameFieldIdMO').getValue())
788 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("Error");
789 if (!sap.ui.getCore().byId('inputMOType').getValue())
790 sap.ui.getCore().byId('inputMOType').setValueState("Error");
791 var msg = 'Please fill the mandatory fields!';
792 sap.m.MessageToast.show(msg);
793 return false;
794 }
795 return true;
796 }
797 },
798 checkDuplicates : function(oEvent) {
799 var router = sap.ui.core.UIComponent.getRouterFor(this);
800 var found = false;
801 if (oEvent.results.length != 0) {
802 console.log("Duplicate TECHNICAL NAME");
803 var oMeasureOb = new sap.ui.model.json.JSONModel(oEvent.results);
804 found = true;
805 console.log(oEvent.results[0]);
806 }
807
808 if (found) {
809
810
811 jQuery.ajax({
812 url: userUrl,
813 method: 'GET',
814 dataType: 'json',
815
816 success: function(user)
817 {
818 username = user.USER;
819 },
820 error: function(XHR, Status, Error)
821 {
822 var error = Error;
823 console.log(XHR.responseText);
824 username = "default";
825 }
826 });
827
828
829
830 if (varPath != undefined) {
831 var that = this;
832 sap.m.MessageBox.show("MO already exists, do you want to assign it to the current package?", {
833 icon : sap.m.MessageBox.Icon.INFORMATION,
834 title : "Info MessageBox",
835 actions : [ sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO ],
836 onClose : function(oAction) {
837 if (oAction === sap.m.MessageBox.Action.YES) {
838 keyPackage = varPath;
839 var dateNew = com.tutorial.util.Formatter.GetUnformattedDate();
840
841 var moOb2 = {
842 "KEY_MEASUREMENT_OBJECTS" : oEvent.results[0].KEY,//moKey,
843 "KEY_PACKAGE" : keyPackage,
844 "CHANGED_BY" : username,
845 "CHANGED_AT" : dateNew
846 };
847 var keyMO = oEvent.results[0].KEY;
848
849 var oDataMOdel = new sap.ui.model.odata.ODataModel(m_xsodata);
850 //oDataMOdel.read("/LEG?$filter=KEY_PACKAGE eq '" + moOb2.KEY_PACKAGE + "' and KEY_MEASUREMENT_OBJECTS eq '" + moOb2.KEY_MEASUREMENT_OBJECTS + "'", null, null, true, fSuccess, fError);
851 oDataMOdel.read("/CL_PACK_MO_DETAILSParameters(IP_PACKAGE_KEY=\'" + moOb2.KEY_PACKAGE + "\')/Results/?$orderby=SORT_COL asc", null, null, true, fSuccess, fError);
852
853 function fSuccess(oEvent) {
854 if (oEvent.results.length != 0) {
855 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("Error");
856 console.log("Assignment already exists");
857 var msg = 'This MO is already assigned to this package';
858 sap.m.MessageToast.show(msg);
859 } else {
860
861 //update the date of assignment of the MO with key_MO
862 var moService = com.tutorial.service.measureobject.MeasurementObjectFactory.getInstance();
863
864 var dateObj = new Date();
865 var month = dateObj.getUTCMonth() + 1; //months from 1-12
866
867 if (month < 10) {
868 month = 0 + month.toString()
869 }
870
871 var day = dateObj.getUTCDate();
872
873 if (day < 10) {
874 day = 0 + day.toString()
875 }
876
877 var year = dateObj.getUTCFullYear();
878
879 var hour = dateObj.getHours();
880
881 if (hour < 10) {
882 hour = 0 + hour.toString()
883 }
884
885 var minutes = dateObj.getMinutes();
886
887 if (minutes < 10) {
888 minutes = 0 + minutes.toString()
889 }
890
891 var seconds = dateObj.getSeconds();
892
893 if (seconds < 10) {
894 seconds = 0 + seconds.toString()
895 }
896
897 var newdate = year.toString() + month.toString() + day.toString() + hour.toString() + minutes.toString() + seconds.toString();
898
899 var moObUpdate = {
900 "DATE_OF_ASSIGNMENT" : newdate
901 };
902
903 moService.updateModel({
904 updatedData : moObUpdate,
905 successFunc : function(moData) {
906 keyPackage = keyPackage;
907
908 },
909 errorFunc : function() {
910 var msg = 'failed to update Measurement Object';
911 sap.m.MessageToast.show(msg);
912 },
913 moKey : keyMO
914 });
915
916 var moprodService = com.tutorial.service.measureobject.MeasurementObjectPMOFactory.getInstance();
917 moprodService.createModel({
918 moData : moOb2,
919 successFunc : function(notesData) {
920 var msg = 'Successfully added';
921 sap.m.MessageToast.show(msg);
922 that.resetField();
923 sap.ui.getCore().byId('inputMOType').setValue("");
924 sap.ui.getCore().byId('inputMOType').setValueState("None");
925
926 sap.ui.getCore().byId('technicalNameFieldIdMO').setValue("");
927 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("None");
928
929 sap.ui.getCore().byId('keyTextFieldId').setValue("");
930 sap.ui.getCore().byId('keyTextFieldId').setValueState("None");
931 router.navTo("Detail", {
932 contextPath : varPath
933 });
934
935 },
936 errorFunc : function() {
937 sap.ui.getCore().byId('inputMOType').setValue("");
938 sap.ui.getCore().byId('inputMOType').setValueState("None");
939
940 sap.ui.getCore().byId('technicalNameFieldIdMO').setValue("");
941 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("None");
942
943 sap.ui.getCore().byId('keyTextFieldId').setValue("");
944 sap.ui.getCore().byId('keyTextFieldId').setValueState("None");
945 var msg = 'failed to add';
946 sap.m.MessageToast.show(msg);
947 }
948 });
949 }
950 }
951 function fError(oEvent) {
952 var msg = 'Unsuccessfully read assignment data';
953 sap.m.MessageToast.show(msg);
954 }
955 //
956
957 } else {
958 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("Error");
959 var msg = 'Technical Name already exists. Please enter a different name';
960 sap.m.MessageToast.show(msg);
961 }
962 }
963
964 });
965 } else {
966 sap.m.MessageBox.show("MO already exists, do you want to display it?", {
967 icon : sap.m.MessageBox.Icon.INFORMATION,
968 title : "Info MessageBox",
969 actions : [ sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO ],
970 linkTitle : "Link",
971 onClose : function(oAction) {
972 if (oAction === sap.m.MessageBox.Action.YES) {
973 router.navTo("DetailMO", {
974 lineItemId : oEvent.results[0].KEY
975 });
976
977 } else {
978 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("Error");
979 var msg = 'Technical Name already exists. Please enter a different name';
980 sap.m.MessageToast.show(msg);
981 }
982 }
983 });
984 }
985 }
986 return !found;
987 },
988
989 //the method addMO is triggered when it's intended to add a mo (add button is pressed)
990 //before adding the new entry, the technical name is checked to see if it already exists
991 // a new entry is added in usag.morepository::Z_USAG_MO
992 addMo : function(evt) {
993 var oTable = sap.ui.getCore().byId("tableMoForPackageId");
994 var that = this;
995 var oBus = sap.ui.getCore().getEventBus();
996 var moService = com.tutorial.service.measureobject.MeasurementObjectFactory.getInstance();
997 var moprodService = com.tutorial.service.measureobject.MeasurementObjectPMOFactory.getInstance();
998 var moKey = this.generateKey();
999 var router = sap.ui.core.UIComponent.getRouterFor(this);
1000 var listMOTYPE;
1001 that = this;
1002
1003 if (this.byId("listMOType").getSelectedItem() == null)
1004 listMOTYPE = null;
1005 else
1006 listMOTYPE = this.byId("listMOType").getSelectedItem().getCustomData()[0].getValue();
1007
1008
1009 if(!this.validateExtendedAttributeField())
1010 return;
1011
1012 var moOb = {
1013 "TECHNICAL_NAME" : sap.ui.getCore().byId('technicalNameFieldIdMO').getValue(),
1014 "DESCRIPTION" : this.byId('descriptionFieldId').getValue(),
1015 "KEY" : sap.ui.getCore().byId('technicalNameFieldIdMO').getValue(),
1016 "NAME" : sap.ui.getCore().byId('keyTextFieldId').getValue(),
1017 "DATE_OF_ENTER" : this.byId('dateFieldID').getValue(),
1018 "FEATUREID" : null,
1019 "PRODUCTID" : null,
1020 "SOLUTIONID" : null,
1021 "FEATURE" : null,
1022 "PRODUCT" : null,
1023 "SOLUTION" : null,
1024 "MO_TYPE" : listMOTYPE,
1025 "UNIT_OF_MEASURE" : this.MOAssigments.UOM,
1026 "AGGREGATION" : this.MOAssigments.AGGREGATION,
1027 "MO_LOGIC" : this.byId('moLogicFieldId').getValue(),
1028 "MEASUREMENT_FREQUENCY" : this.MOAssigments.Frequency,
1029 "MEASUREMENT_METHOD" : this.MOAssigments.Status,
1030 "STEREOTYPE": this.MOAssigments.Stereotype.split('/').pop(),
1031 "ACTIVE": 'yes',
1032 "OWNER" : username
1033 };
1034 console.log("owneeeeeeeeeer2" + moOb.OWNER + username)
1035
1036
1037 if (this.checkEmptyFields())
1038
1039 {
1040
1041 jQuery.ajax({
1042 url: userUrl,
1043 method: 'GET',
1044 dataType: 'json',
1045
1046 success: function(user)
1047 {
1048 username = user.USER;
1049 },
1050 error: function(XHR, Status, Error)
1051 {
1052 var error = Error;
1053 console.log(XHR.responseText);
1054 username = "default";
1055 }
1056 });
1057
1058 var oDataMOdel = new sap.ui.model.odata.ODataModel(m_xsodata);
1059 oDataMOdel.read("/MEASUREMENT_OBJECTS?$filter=TECHNICAL_NAME eq '" + moOb.TECHNICAL_NAME + "'", null, null, true, fSuccess, fError);
1060 function fSuccess(oEvent) {
1061 if (that.checkDuplicates(oEvent)) {
1062 moService.createModel({
1063 moData : moOb,
1064 successFunc : function(notesData) {
1065 that.addExtendedAttributes();
1066 var oTable = sap.ui.getCore().byId("tableMoForPackageId");
1067 if (varPath != undefined) {
1068 keyPackage = varPath;
1069 var dateNew = com.tutorial.util.Formatter.GetUnformattedDate();
1070 var moOb2 = {
1071 "KEY_MEASUREMENT_OBJECTS" : sap.ui.getCore().byId('technicalNameFieldIdMO').getValue(),
1072 "KEY_PACKAGE" : keyPackage,
1073 "CHANGED_BY" : username,
1074 "CHANGED_AT" : dateNew
1075 };
1076 moprodService.createModel({
1077 moData : moOb2,
1078 successFunc : function(notesData) {
1079// that.validateExtendedAttributeField();
1080 var msg = 'Measurement Object successfully added';
1081 sap.m.MessageToast.show(msg);
1082 that.resetField();
1083 sap.ui.getCore().byId('inputMOType').setValue("");
1084 sap.ui.getCore().byId('inputMOType').setValueState("None");
1085
1086 sap.ui.getCore().byId('technicalNameFieldIdMO').setValue("");
1087 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("None");
1088
1089 sap.ui.getCore().byId('keyTextFieldId').setValue("");
1090 sap.ui.getCore().byId('keyTextFieldId').setValueState("None");
1091
1092 router.navTo("Detail", {
1093 contextPath : varPath,
1094 contextID : "1"
1095 });
1096
1097 },
1098 errorFunc : function() {
1099 sap.ui.getCore().byId('inputMOType').setValue("");
1100 sap.ui.getCore().byId('inputMOType').setValueState("None");
1101
1102 sap.ui.getCore().byId('technicalNameFieldIdMO').setValue("");
1103 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("None");
1104
1105 sap.ui.getCore().byId('keyTextFieldId').setValue("");
1106 sap.ui.getCore().byId('keyTextFieldId').setValueState("None");
1107 var msg = 'Unsuccessfully added';
1108 sap.m.MessageToast.show(msg);
1109 }
1110 });
1111 } else {
1112 that.resetField();
1113 if (sap.ui.getCore().byId("iconTabBar1") == undefined)
1114 router.navTo("main");
1115 else {
1116 router.navTo("main", {
1117 query : {
1118 tab : sap.ui.getCore().byId("iconTabBar1").getSelectedKey()
1119 }
1120 }, true);
1121 }
1122 sap.ui.getCore().byId('inputMOType').setValue("");
1123 sap.ui.getCore().byId('inputMOType').setValueState("None");
1124
1125 sap.ui.getCore().byId('technicalNameFieldIdMO').setValue("");
1126 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("None");
1127
1128 sap.ui.getCore().byId('keyTextFieldId').setValue("");
1129 sap.ui.getCore().byId('keyTextFieldId').setValueState("None");
1130 }
1131 },
1132 errorFunc : function() {
1133
1134 sap.m.MessageToast.show('failed to add Measurement Object');
1135
1136 sap.ui.getCore().byId('inputMOType').setValue("");
1137 sap.ui.getCore().byId('inputMOType').setValueState("None");
1138
1139 sap.ui.getCore().byId('technicalNameFieldIdMO').setValue("");
1140 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("None");
1141
1142 sap.ui.getCore().byId('keyTextFieldId').setValue("");
1143 sap.ui.getCore().byId('keyTextFieldId').setValueState("None");
1144 }
1145 });
1146
1147 }
1148 }
1149 ;
1150 function fError(oEvent) {
1151 console.log("An error occured while reading Measurement Object Data!")
1152 }
1153 ;
1154 }
1155
1156 },
1157
1158 // after the mo was successfully added, the method resetField is called to reset all the fields to null value
1159 resetField : function() {
1160 sap.ui.getCore().byId('technicalNameFieldIdMO').setValue("");
1161 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("None");
1162
1163 sap.ui.getCore().byId('keyTextFieldId').setValue("");
1164 sap.ui.getCore().byId('keyTextFieldId').setValueState("None");
1165
1166 this.byId('descriptionFieldId').setValue("");
1167
1168 // this.byId('inputField').setValue("");
1169 //this.byId('inputSolution').setValue("");
1170 sap.ui.getCore().byId('inputMOType').setValue("");
1171 this.byId('inputUOM').setValue("");
1172 this.byId('inputAGGREGATION').setValue("");
1173 this.byId('moLogicFieldId').setValue("");
1174 this.byId('inputFrequency').setValue("");
1175 this.byId('inputStereotype').setValue("");
1176 this.byId('inputStatus').setValue("");
1177 },
1178
1179 //quickhelp function
1180 quickhelp: function(oControl, sText, bCustomize){
1181 // create the RichTooltip control
1182 var oRichTooltip = new sap.ui.commons.RichTooltip({
1183 text: sText,
1184 title: "Quick Help",
1185 imageSrc: "images/Tip.gif"
1186 });
1187 // Change position and durations if required
1188 if (bCustomize) {
1189 oRichTooltip.setMyPosition("begin top");
1190 oRichTooltip.setAtPosition("end top");
1191 oRichTooltip.setOpenDuration(300);
1192 oRichTooltip.setCloseDuration(300);
1193 }
1194 // add it to the control
1195 oControl.setTooltip(oRichTooltip);
1196 // return the control itself (makes this function a
1197 // decorator function)
1198 return oControl;
1199 },
1200
1201 validateNames: function(){
1202 var name = sap.ui.getCore().byId('technicalNameFieldIdMO').getValue();
1203 var technicalName = sap.ui.getCore().byId('keyTextFieldId').getValue();
1204
1205 if(name == null || name == undefined || name == ""){
1206 sap.ui.getCore().byId('keyTextFieldId').setValue("");
1207 sap.ui.getCore().byId('keyTextFieldId').setValueState("Error");
1208 }
1209 if(technicalName == null || technicalName == undefined || technicalName == ""){
1210 sap.ui.getCore().byId('technicalNameFieldIdMO').setValue("");
1211 sap.ui.getCore().byId('technicalNameFieldIdMO').setValueState("Error");
1212 }
1213 },
1214
1215 validateExtendedAttributeField: function(){
1216
1217 var flag = 1;
1218 if(this.extendedAttributes != null && this. extendedAttributes!= undefined){
1219 for(var attribute of this.extendedAttributes){
1220 var name = attribute;
1221 var value = sap.ui.getCore().byId('Value' + attribute).getValue();
1222 var managedBy = sap.ui.getCore().byId('Managed' + attribute).getText();
1223
1224
1225
1226 }
1227 }
1228
1229 if(flag == 0)
1230 return false;
1231
1232 return true;
1233 },
1234
1235 saveExtendedAttributes: function (moKey) {
1236 if(this.extendedAttributes != null && this.extendedAttributes != undefined){
1237 extendedAttributesTableData = {
1238 packId: moKey,
1239 extendedAttributesValues: []
1240 };
1241 this.extendedAttributes.forEach(attribute => {
1242 var name = attribute;
1243 var value = sap.ui.getCore().byId('Value' + attribute).getValue();
1244 var managedBy = sap.ui.getCore().byId('Managed' + attribute).getText();
1245 extendedAttributesTableData.extendedAttributesValues.push({name: name, value: value, managedBy: managedBy});
1246 });
1247 }
1248
1249 },
1250
1251 addExtendedAttributes: function(){
1252 var that=this;
1253 var table = this.getView().byId(this.createId("addMoTable"));
1254 table.getItems().forEach(function(ColListItem){
1255 var attribute={};
1256 attribute.name = ColListItem.getCells()[0].getText();
1257 attribute.value = ColListItem.getCells()[1].getValue();
1258 attribute.managedBy = ColListItem.getCells()[2].getText();
1259 that.saveAttribute(attribute);
1260 })
1261 },
1262
1263 saveAttribute: function(attribute){
1264 debugger;
1265 var that = this;
1266 var obj_type = 'Z_USAG_MO';
1267 var action_type = 'insert';
1268 var datatype = 'String';
1269
1270 var url = UpdateExtendedAttributesDataURL + "?obj_type=" + obj_type + "&action_type=" + action_type + "&datatype=" + datatype + "&obj_id=" + sap.ui.getCore().byId('technicalNameFieldIdMO').getValue() + "&attribute=" + attribute.name + "&value=" + attribute.value + "&managed_by=" + attribute.managedBy;
1271 jQuery.ajax({
1272 url: url,
1273 method: 'GET',
1274 //dataType: 'json',
1275 success: function(XHR, Status, Error)
1276 {
1277 if(Error){console.log(Error)}
1278
1279 },
1280 error: function(XHR, Status, Error)
1281 {
1282 console.log(Error)
1283 }
1284 });
1285
1286 },
1287
1288});