Skip to content
Open
Show file tree
Hide file tree
Changes from all 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);
}
}
2 changes: 0 additions & 2 deletions app/styles/local.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ div[doi-format].power-select-fragment .ember-basic-dropdown-trigger div.ember-vi
/* VALIDATION - FORM-GROUPS */

.form-group .form-text {
font-size: 16px;
display: block;
margin-top: 5px;
margin-bottom: 10px;
Expand Down Expand Up @@ -555,7 +554,6 @@ div[doi-publisher] > div {
.form-group input.is-valid + div.form-text {
color: #2ecc71;
}
*/

/* VALIDATION - text areas (Mostly in doi form upload.) */

Expand Down
317 changes: 158 additions & 159 deletions app/templates/providers/show/repositories/new.hbs

Large diffs are not rendered by default.

320 changes: 160 additions & 160 deletions app/templates/repositories/show/edit.hbs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/integration/helpers/repository-form-errors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ module('Integration | Helper | repository-form-errors', function (hooks) {

await render(hbs`{{repository-form-errors this.model}}`);

assert.dom(this.element).hasText('repository ID, confirm repository ID');
assert.dom(this.element).hasText('repository ID, confirm repository ID, software');
});
});
Loading