mirror of https://github.com/rancher/ui.git
parent
6eda0f7b2b
commit
6329d214fa
|
|
@ -70,31 +70,11 @@ export default Component.extend(NewOrEdit,{
|
||||||
return get(this, 'globalStore').createRecord(role);
|
return get(this, 'globalStore').createRecord(role);
|
||||||
},
|
},
|
||||||
|
|
||||||
validate: function () {
|
|
||||||
var errors = [];
|
|
||||||
if ((get(this, 'primaryResource.subjectName') || '').trim().length === 0) {
|
|
||||||
errors.push(get(this, 'intl').findTranslationByKey('formScopedRoles.errors.userRequired'));
|
|
||||||
}
|
|
||||||
if (errors.length) {
|
|
||||||
set(this, 'errors', errors.uniq());
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
set(this, 'errors', null);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
cancel() {
|
cancel() {
|
||||||
this.sendAction('cancel');
|
this.sendAction('cancel');
|
||||||
},
|
},
|
||||||
save(cb) {
|
save(cb) {
|
||||||
if(!this.validate()) {
|
|
||||||
if ( cb ) {
|
|
||||||
cb();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let mode = get(this, 'mode');
|
let mode = get(this, 'mode');
|
||||||
let add = [];
|
let add = [];
|
||||||
let remove = [];
|
let remove = [];
|
||||||
|
|
@ -118,6 +98,13 @@ export default Component.extend(NewOrEdit,{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!this.validate()) {
|
||||||
|
if ( cb ) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return PromiseAll(add.map(x => x.save())).then(() => {
|
return PromiseAll(add.map(x => x.save())).then(() => {
|
||||||
return PromiseAll(remove.map(x => x.delete())).then(() => {
|
return PromiseAll(remove.map(x => x.delete())).then(() => {
|
||||||
return this.doneSaving();
|
return this.doneSaving();
|
||||||
|
|
|
||||||
|
|
@ -2262,8 +2262,6 @@ formGlobalRoles:
|
||||||
formScopedRoles:
|
formScopedRoles:
|
||||||
title: '{type} Permissions'
|
title: '{type} Permissions'
|
||||||
description: 'Controls what access users have to the {type}.'
|
description: 'Controls what access users have to the {type}.'
|
||||||
errors:
|
|
||||||
userRequired: Please select a user.
|
|
||||||
|
|
||||||
mode:
|
mode:
|
||||||
admin:
|
admin:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue