Skip to content

Commit

Permalink
use model in creator validation. #192
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Apr 21, 2019
1 parent 8a1273b commit 1240b86
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/models/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ const Validations = buildValidations({
'name': [
validator('presence', {
presence: true,
isWarning: computed('model.model.state', 'model.model.prefix', function () {
return (this.get('model.model.state') === 'draft' || this.get('model.model.prefix') === '10.5072');
isWarning: computed('model._internalModel._recordData.getOwner()', function () {
// workaround to look up owner
let owner = this.model._internalModel._recordData.getOwner();
return owner.state === 'draft' || owner.prefix === '10.5072';
}),
disabled: computed('model.model.mode', function () {
return !["new", "edit"].includes(this.get('model.model.mode'));
disabled: computed('model._internalModel._recordData.getOwner()', function () {
// only validate first creator
let owner = this.model._internalModel._recordData.getOwner();
return this.model !== owner.creators.content[0];
})
})
]
Expand Down

0 comments on commit 1240b86

Please sign in to comment.