Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
469 changes: 238 additions & 231 deletions app/controllers/providers/show/repositories/new.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions app/controllers/repositories/show/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default class EditController extends Controller {
re3data = null;
softwareList = softwareList;
softwares = softwareList;
isSoftwareFieldActive = false;
clientTypeList = clientTypeList;
clientTypes = clientTypeList;

Expand Down Expand Up @@ -185,4 +186,10 @@ export default class EditController extends Controller {
this.model.rollbackAttributes();
this.router.transitionTo('repositories.show', this.model);
}

// This helps to manage the validation state of the software field. The field is required, but we don't want to show it as invalid until the user has interacted with it.
@action
activateSoftwareField() {
return this.set('isSoftwareFieldActive', true);
}
}
3 changes: 3 additions & 0 deletions app/models/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ const Validations = buildValidations({
allowBlank: true,
message: 'ISSN (print) is in the wrong format.'
})
],
software: [
validator('presence', true)
]
});

Expand Down
18 changes: 18 additions & 0 deletions app/routes/providers/show/repositories/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,22 @@ export default class NewRoute extends Route {
})
});
}

setupController(controller, model) {
// Call _super to maintain default behavior (controller.set('model', model))
super.setupController(controller, model);

// Custom setup: Set additional properties
controller.set('isSoftwareFieldActive', false);
}

resetController(controller, isExiting, transition) {
// If the user is exiting the route entirely, reset the transient properties
if (isExiting) {
controller.set('isSoftwareFieldActive', false);
}

// Calls the default resetController behavior (important for query params)
super.resetController(controller, isExiting, transition);
}
}
11 changes: 11 additions & 0 deletions app/routes/repositories/show/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,16 @@ export default class EditRoute extends Route {

controller.set('clientTypeList', filteredClientTypeList);
controller.set('clientTypes', filteredClientTypeList);
controller.set('isSoftwareFieldActive', false);
}

resetController(controller, isExiting, transition) {
// If the user is exiting the route entirely, reset the transient properties
if (isExiting) {
controller.set('isSoftwareFieldActive', false);
}

// Calls the default resetController behavior (important for query params)
super.resetController(controller, isExiting, transition);
}
}
Loading
Loading