implement model based copy for inventory scripts

This commit is contained in:
Jake McDermott 2017-12-05 17:51:47 -05:00
parent d56f1a0120
commit a680d188c0
No known key found for this signature in database
GPG Key ID: 3B02CAD476EECB35
2 changed files with 24 additions and 0 deletions

View File

@ -57,6 +57,15 @@ export default ['i18n', function(i18n){
dataPlacement: 'top',
ngShow: 'inventory_script.summary_fields.user_capabilities.edit'
},
copy: {
label: i18n._('Copy'),
ngClick: 'copyCustomInv(inventory_script)',
"class": 'btn-danger btn-xs',
awToolTip: i18n._('Copy inventory scruot'),
dataPlacement: 'top',
// requires future api rbac changes
//ngShow: 'inventory_script.summary_fields.user_capabilities.copy'
},
view: {
ngClick: "editCustomInv(inventory_script.id)",
label: i18n._('View'),

View File

@ -47,6 +47,21 @@ export default ['$rootScope', '$scope', 'Wait', 'InventoryScriptsList',
});
};
$scope.copyCustomInv = inventoryScript => {
Wait('start');
new InventoryScript('get', inventoryScript.id)
.then(model => model.copy())
.then(({ id }) => {
const params = { inventory_script_id: id };
$state.go('inventoryScripts.edit', params, { reload: true });
})
.catch(({ data, status }) => {
const params = { hdr: 'Error!', msg: `Call to copy failed. Return status: ${status}` };
ProcessErrors($scope, data, status, null, params);
})
.finally(() => Wait('stop'));
};
$scope.deleteCustomInv = function(id, name) {
var action = function() {