Defined delete string in the base with the ability to pass the resource name in

This commit is contained in:
mabashian 2017-11-22 13:28:02 -05:00
parent 565b0b82dd
commit d3da899459
No known key found for this signature in database
GPG Key ID: 436B8D5EDC704CE3
13 changed files with 18 additions and 52 deletions

View File

@ -60,6 +60,10 @@ function BaseStringService (namespace) {
this.CANCEL = t.s('CANCEL');
this.SAVE = t.s('SAVE');
this.OK = t.s('OK');
this.deleteResource = {
USED_BY: resourceType => t.s('The {{ resourceType }} is currently being used by other resources.', { resourceType }),
CONFIRM: resourceType => t.s('Are you sure you want to delete this {{ resourceType }}?', { resourceType })
};
/**
* This getter searches the extending class' namespace first for a match then falls back to

View File

@ -5,7 +5,6 @@ function CredentialTypesStrings (BaseString) {
let ns = this.credential_types;
ns.deleteCredentialType = {
CONFIRM: t.s('Are you sure you want to delete this credential type?'),
CREDENTIAL_TYPE_IN_USE: t.s('This credential type is currently being used by one or more credentials. Credentials that use this credential type must be deleted before the credential type can be deleted.')
};
}

View File

@ -90,7 +90,7 @@ export default ['$rootScope', '$scope', 'Wait', 'CredentialTypesList',
credentialType.getDependentResourceCounts(id)
.then((counts) => {
let credentialTypeInUse = false;
let deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialTypesStrings.get('deleteCredentialType.CONFIRM')}</div>`;
let deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialTypesStrings.get('deleteResource.CONFIRM', 'credential type')}</div>`;
counts.forEach(countObj => {
if(countObj.count && countObj.count > 0) {

View File

@ -114,7 +114,7 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
credential.getDependentResourceCounts(id)
.then((counts) => {
const invalidateRelatedLines = [];
let deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialsStrings.get('deleteCredential.CONFIRM')}</div>`;
let deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialsStrings.get('deleteResource.CONFIRM', 'credential')}</div>`;
counts.forEach(countObj => {
if(countObj.count && countObj.count > 0) {
@ -123,7 +123,7 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
});
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialsStrings.get('deleteCredential.CONFIRM')}</div>`;
deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialsStrings.get('deleteResource.USED_BY', 'credential')} ${CredentialsStrings.get('deleteResource.CONFIRM', 'credential')}</div>`;
invalidateRelatedLines.forEach(invalidateRelatedLine => {
deleteModalBody += invalidateRelatedLine;
});

View File

@ -101,7 +101,7 @@ function InventoriesList($scope,
inventory.getDependentResourceCounts(id)
.then((counts) => {
const invalidateRelatedLines = [];
let deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteInventory.CONFIRM')}</div>`;
let deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteResource.CONFIRM', 'inventory')}</div>`;
counts.forEach(countObj => {
if(countObj.count && countObj.count > 0) {
@ -110,7 +110,7 @@ function InventoriesList($scope,
});
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteInventory.CONFIRM')}</div>`;
deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteResource.USED_BY', 'inventory')} ${InventoryHostsStrings.get('deleteResource.CONFIRM', 'inventory')}</div>`;
invalidateRelatedLines.forEach(invalidateRelatedLine => {
deleteModalBody += invalidateRelatedLine;
});

View File

@ -143,7 +143,7 @@
inventorySource.getDependentResourceCounts(inventory_source.id)
.then((counts) => {
const invalidateRelatedLines = [];
let deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteSource.CONFIRM')}</div>`;
let deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteResource.CONFIRM', 'inventory source')}</div>`;
counts.forEach(countObj => {
if(countObj.count && countObj.count > 0) {
@ -152,7 +152,7 @@
});
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteSource.CONFIRM')}</div>`;
deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteResource.USED_BY', 'inventory source')} ${InventoryHostsStrings.get('deleteResource.CONFIRM', 'inventory source')}</div>`;
invalidateRelatedLines.forEach(invalidateRelatedLine => {
deleteModalBody += invalidateRelatedLine;
});

View File

@ -4,14 +4,6 @@ function InventoryHostsStrings (BaseString) {
let t = this.t;
let ns = this['inventory-hosts'];
ns.deleteInventory = {
CONFIRM: t.s('The inventory is currently being used by other resources. Are you sure you want to delete this inventory?')
};
ns.deleteSource = {
CONFIRM: t.s('The inventory source is currently being used by other resources. Are you sure you want to delete this inventory source?')
};
ns.deletegroup = {
GROUP: count => t.p(count, 'group', 'groups'),
HOST: count => t.p(count, 'host', 'hosts'),

View File

@ -1,12 +1,5 @@
function InventoryScriptsStrings (BaseString) {
BaseString.call(this, 'inventory_scripts');
let t = this.t;
let ns = this.inventory_scripts;
ns.deleteInventoryScript = {
CONFIRM: t.s('The inventory script is currently being used by other resources. Are you sure you want to delete this inventory script?')
};
}
InventoryScriptsStrings.$inject = ['BaseStringService'];

View File

@ -80,7 +80,7 @@ export default ['$rootScope', '$scope', 'Wait', 'InventoryScriptsList',
inventoryScript.getDependentResourceCounts(id)
.then((counts) => {
const invalidateRelatedLines = [];
let deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryScriptsStrings.get('deleteInventoryScript.CONFIRM')}</div>`;
let deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryScriptsStrings.get('deleteResource.CONFIRM', 'inventory script')}</div>`;
counts.forEach(countObj => {
if(countObj.count && countObj.count > 0) {
@ -89,7 +89,7 @@ export default ['$rootScope', '$scope', 'Wait', 'InventoryScriptsList',
});
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryScriptsStrings.get('deleteInventoryScript.CONFIRM')}</div>`;
deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryScriptsStrings.get('deleteResource.USED_BY', 'inventory script')} ${InventoryScriptsStrings.get('deleteResource.CONFIRM', 'inventory script')}</div>`;
invalidateRelatedLines.forEach(invalidateRelatedLine => {
deleteModalBody += invalidateRelatedLine;
});

View File

@ -206,7 +206,7 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
project.getDependentResourceCounts(id)
.then((counts) => {
const invalidateRelatedLines = [];
let deleteModalBody = `<div class="Prompt-bodyQuery">${ProjectsStrings.get('deleteProject.CONFIRM')}</div>`;
let deleteModalBody = `<div class="Prompt-bodyQuery">${ProjectsStrings.get('deleteResource.CONFIRM', 'project')}</div>`;
counts.forEach(countObj => {
if(countObj.count && countObj.count > 0) {
@ -215,7 +215,7 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
});
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
deleteModalBody = `<div class="Prompt-bodyQuery">${ProjectsStrings.get('deleteProject.CONFIRM')}</div>`;
deleteModalBody = `<div class="Prompt-bodyQuery">${ProjectsStrings.get('deleteResource.USED_BY', 'project')} ${ProjectsStrings.get('deleteResource.CONFIRM', 'project')}</div>`;
invalidateRelatedLines.forEach(invalidateRelatedLine => {
deleteModalBody += invalidateRelatedLine;
});

View File

@ -1,12 +1,5 @@
function ProjectsStrings (BaseString) {
BaseString.call(this, 'projects');
let t = this.t;
let ns = this.projects;
ns.deleteProject = {
CONFIRM: t.s('The project is currently being used by other resources. Are you sure you want to delete this project?')
};
}
ProjectsStrings.$inject = ['BaseStringService'];

View File

@ -154,7 +154,7 @@ export default ['$scope', '$rootScope',
Prompt({
hdr: i18n._('Delete'),
resourceName: $filter('sanitize')(template.name),
body: TemplatesStrings.get('workflowJobTemplates.deleteWorkflowJobTemplate.CONFIRM'),
body: TemplatesStrings.get('deleteResource.CONFIRM', 'workflow job template'),
action: action,
actionText: 'DELETE'
});
@ -164,7 +164,7 @@ export default ['$scope', '$rootScope',
jobTemplate.getDependentResourceCounts(template.id)
.then((counts) => {
const invalidateRelatedLines = [];
let deleteModalBody = `<div class="Prompt-bodyQuery">${TemplatesStrings.get('jobTemplates.deleteJobTemplate.CONFIRM')}</div>`;
let deleteModalBody = `<div class="Prompt-bodyQuery">${TemplatesStrings.get('deleteResource.CONFIRM', 'job template')}</div>`;
counts.forEach(countObj => {
if(countObj.count && countObj.count > 0) {
@ -173,7 +173,7 @@ export default ['$scope', '$rootScope',
});
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
deleteModalBody = `<div class="Prompt-bodyQuery">${TemplatesStrings.get('jobTemplates.deleteJobTemplate.CONFIRM')}</div>`;
deleteModalBody = `<div class="Prompt-bodyQuery">${TemplatesStrings.get('deleteResource.USED_BY', 'job template')} ${TemplatesStrings.get('deleteResource.CONFIRM', 'job template')}</div>`;
invalidateRelatedLines.forEach(invalidateRelatedLine => {
deleteModalBody += invalidateRelatedLine;
});

View File

@ -1,20 +1,5 @@
function TemplatesStrings (BaseString) {
BaseString.call(this, 'templates');
let t = this.t;
let ns = this.templates;
ns.jobTemplates = {
deleteJobTemplate: {
CONFIRM: t.s('The job template is currently being used by other resources. Are you sure you want to delete this job template?')
}
};
ns.workflowJobTemplates = {
deleteWorkflowJobTemplate: {
CONFIRM: t.s('Are you sure you want to delete this workflow job template?')
}
};
}
TemplatesStrings.$inject = ['BaseStringService'];