|
258 |
|
258 |
|
259 |
// add a context menu to edit/delete items |
259 |
// add a context menu to edit/delete items |
260 |
var menu = new Menu({}); |
260 |
var menu = new Menu({}); |
261 |
menu.addChild(new MenuItem({ |
261 |
menu.addChild(this._menuEdit = new MenuItem({ |
262 |
label: _( 'Edit' ), |
262 |
label: _( 'Edit' ), |
263 |
iconClass: 'umcIconEdit', |
263 |
iconClass: 'umcIconEdit', |
264 |
onClick: lang.hitch(this, function(e) { |
264 |
onClick: lang.hitch(this, function() { |
265 |
if(this._navContextItem) { |
265 |
console.log(this._navContextItem.id); |
266 |
if(this._navContextItem.type == 'cloud' && this._navContextItem.dn) { |
266 |
this._editCloudConnection(this._navContextItem); |
267 |
require('umc/app').openModule('udm', 'uvmm/cloudconnection',{'openObject': {'objectDN': this._navContextItem.dn, 'objectType': 'uvmm/cloudconnection'}}); |
267 |
}) |
268 |
} else if(this._navContextItem.type == 'cloud' || (this._navContextItem.type == 'group' && this._navContextItem.id == 'cloudconnections')) { |
268 |
})); |
269 |
require('umc/app').openModule('udm', 'uvmm/cloudconnection'); |
269 |
menu.addChild(this._menuDelete = new MenuItem({ |
270 |
} |
|
|
271 |
} |
272 |
})})); |
273 |
/* menu.addChild(new MenuItem({ |
274 |
label: _( 'Delete' ), |
270 |
label: _( 'Delete' ), |
275 |
iconClass: 'umcIconDelete', |
271 |
iconClass: 'umcIconDelete', |
276 |
onClick: lang.hitch(this, function() { |
272 |
onClick: lang.hitch(this, function() { |
277 |
this.removeObjects(this._navContextItem.id); |
273 |
this.removeObjects(this._navContextItem.id); |
278 |
}) |
274 |
}) |
279 |
}));*/ |
275 |
})); |
280 |
menu.addChild(new MenuItem({ |
276 |
menu.addChild(new MenuItem({ |
281 |
label: _( 'Reload' ), |
277 |
label: _( 'Reload' ), |
282 |
iconClass: 'umcIconRefresh', |
278 |
iconClass: 'umcIconRefresh', |
|
295 |
}), true)); |
291 |
}), true)); |
296 |
this.own(aspect.before(menu, '_openMyself', lang.hitch(this, function() { |
292 |
this.own(aspect.before(menu, '_openMyself', lang.hitch(this, function() { |
297 |
this._navContextItem = this._navContextItemFocused; |
293 |
this._navContextItem = this._navContextItemFocused; |
|
|
294 |
this._updateMenuAvailability(); |
298 |
}))); |
295 |
}))); |
299 |
|
296 |
|
300 |
// when we right-click anywhere on the tree, make sure we open the menu |
297 |
// when we right-click anywhere on the tree, make sure we open the menu |
|
348 |
this._domainPage.on('UpdateProgress', lang.hitch(this, 'updateProgress')); |
345 |
this._domainPage.on('UpdateProgress', lang.hitch(this, 'updateProgress')); |
349 |
}, |
346 |
}, |
350 |
|
347 |
|
|
|
348 |
_updateMenuAvailability: function() { |
349 |
var item = this._navContextItemFocused; |
350 |
var canEdit = item.type == 'cloud' && item.dn; |
351 |
var canDelete = canEdit; |
352 |
this._menuEdit.set('disabled', !canEdit); |
353 |
this._menuDelete.set('disabled', !canDelete); |
354 |
}, |
355 |
|
351 |
postCreate: function() { |
356 |
postCreate: function() { |
352 |
this.inherited(arguments); |
357 |
this.inherited(arguments); |
353 |
|
358 |
|
|
744 |
this.selectChild(wizard); |
749 |
this.selectChild(wizard); |
745 |
}, |
750 |
}, |
746 |
|
751 |
|
|
|
752 |
_editCloudConnection: function(item) { |
753 |
var values = {cloudtype: item.cloudtype}; |
754 |
this._addCloudConnection(values).then(lang.hitch(this, function(wizard) { |
755 |
tools.forIn(wizard._pages, function(pageName, page) { |
756 |
tools.forIn(item.params, function(key, value) { |
757 |
var widget = wizard.getWidget(pageName, key); |
758 |
if (widget) { |
759 |
widget.set('value', value); |
760 |
} |
761 |
}); |
762 |
}); |
763 |
})); |
764 |
}, |
765 |
|
747 |
_addCloudConnection: function(values) { |
766 |
_addCloudConnection: function(values) { |
748 |
var wizard = null; |
767 |
var wizard = null; |
749 |
|
768 |
|
|
786 |
tools.defer(wait, 1000); |
805 |
tools.defer(wait, 1000); |
787 |
}); |
806 |
}); |
788 |
|
807 |
|
789 |
this.loadWizardPages(values.cloudtype).then(lang.hitch(this, function(Wizard) { |
808 |
return this.loadWizardPages(values.cloudtype).then(lang.hitch(this, function(Wizard) { |
790 |
wizard = new Wizard({ |
809 |
wizard = new Wizard({ |
791 |
autoValidate: true, |
810 |
autoValidate: true, |
792 |
onFinished: _finished, |
811 |
onFinished: _finished, |
|
797 |
}); |
816 |
}); |
798 |
this.addChild(wizard); |
817 |
this.addChild(wizard); |
799 |
this.selectChild(wizard); |
818 |
this.selectChild(wizard); |
|
|
819 |
return wizard; |
800 |
})); |
820 |
})); |
801 |
}, |
821 |
}, |
802 |
|
822 |
|