diff --git a/LesionTracker/client/components/app/app.html b/LesionTracker/client/components/app/app.html index af15464c0..c43bbcb57 100644 --- a/LesionTracker/client/components/app/app.html +++ b/LesionTracker/client/components/app/app.html @@ -31,7 +31,6 @@
- {{ >associationModal }} {{ >optionsModal }} {{ >serverInformationModal }} {{ >confirmRemoveTimepointAssociation }} diff --git a/LesionTracker/client/routes.js b/LesionTracker/client/routes.js index c59891764..a09188878 100644 --- a/LesionTracker/client/routes.js +++ b/LesionTracker/client/routes.js @@ -12,7 +12,6 @@ Router.onBeforeAction('loading'); var data = { additionalTemplates: [ - 'associationModal', 'optionsModal', 'serverInformationModal', 'confirmRemoveTimepointAssociation', diff --git a/PETSUVMeasurements/client/components/app/app.html b/PETSUVMeasurements/client/components/app/app.html index c76a9b5df..d10c95c84 100644 --- a/PETSUVMeasurements/client/components/app/app.html +++ b/PETSUVMeasurements/client/components/app/app.html @@ -31,7 +31,6 @@
- {{ >associationModal }} {{ >serverInformationModal }} {{ >lastLoginModal }} {{ >studyContextMenu }} diff --git a/Packages/ohif-core/client/components/base/index.js b/Packages/ohif-core/client/components/base/index.js index 4e3539a0f..34865171b 100644 --- a/Packages/ohif-core/client/components/base/index.js +++ b/Packages/ohif-core/client/components/base/index.js @@ -8,14 +8,16 @@ import './section/section.html'; import './section/section.js'; // Mixins +import './mixins/action.js'; import './mixins/button.js'; +import './mixins/checkbox.js'; import './mixins/component.js'; import './mixins/form.js'; import './mixins/formItem.js'; import './mixins/group.js'; import './mixins/groupRadio.js'; import './mixins/input.js'; -import './mixins/checkbox.js'; +import './mixins/link.js'; import './mixins/schemaData.js'; import './mixins/select.js'; import './mixins/select2.js'; @@ -27,6 +29,7 @@ import './templates/custom.html'; import './templates/div.html'; import './templates/form.html'; import './templates/input.html'; +import './templates/link.html'; import './templates/select.html'; // wrappers diff --git a/Packages/ohif-core/client/components/base/mixins/action.js b/Packages/ohif-core/client/components/base/mixins/action.js new file mode 100644 index 000000000..d645b93c4 --- /dev/null +++ b/Packages/ohif-core/client/components/base/mixins/action.js @@ -0,0 +1,37 @@ +import { OHIF } from 'meteor/ohif:core'; +import { Template } from 'meteor/templating'; + +/* + * action: controls an element that will trigger some form API's method + */ +OHIF.mixins.action = new OHIF.Mixin({ + dependencies: 'formItem', + composition: { + onRendered() { + const instance = Template.instance(); + const component = instance.component; + + component.$element.addClass('form-action'); + }, + + events: { + 'click .form-action'(event, instance) { + const component = instance.component; + + // Extract the action and the params + const { action, params } = instance.data; + + // Get the current component's API + const api = component.getApi(); + + // Stop here if no API or action was defined + if (!api || !action || typeof api[action] !== 'function') { + return; + } + + // Call the defined action function + api[action].call(this, params); + } + } + } +}); diff --git a/Packages/ohif-core/client/components/base/mixins/button.js b/Packages/ohif-core/client/components/base/mixins/button.js index 2c04eceb0..990da612e 100644 --- a/Packages/ohif-core/client/components/base/mixins/button.js +++ b/Packages/ohif-core/client/components/base/mixins/button.js @@ -2,7 +2,7 @@ import { OHIF } from 'meteor/ohif:core'; import { Template } from 'meteor/templating'; /* - * input: controls a button + * button: controls a button */ OHIF.mixins.button = new OHIF.Mixin({ dependencies: 'formItem', @@ -13,26 +13,6 @@ OHIF.mixins.button = new OHIF.Mixin({ // Set the element to be controlled component.$element = instance.$('button:first'); - }, - - events: { - 'click button'(event, instance) { - const component = instance.component; - - // Extract the action and the params - const { action, params } = instance.data; - - // Get the current component's API - const api = component.getApi(); - - // Stop here if no API or action was defined - if (!api || !action || typeof api[action] !== 'function') { - return; - } - - // Call the defined action function - api[action].call(this, params); - } } } }); diff --git a/Packages/ohif-core/client/components/base/mixins/form.js b/Packages/ohif-core/client/components/base/mixins/form.js index a3a4d5609..62f25786a 100644 --- a/Packages/ohif-core/client/components/base/mixins/form.js +++ b/Packages/ohif-core/client/components/base/mixins/form.js @@ -55,10 +55,12 @@ OHIF.mixins.form = new OHIF.Mixin({ // Set the component main and style elements component.$style = component.$element = instance.$('form:first'); + + // Block page redirecting on submit + component.$element[0].onsubmit = () => false; }, events: { - submit: event => event.preventDefault(), 'click .validation-error-container a'(event, instance) { // Get the target key const targetKey = $(event.currentTarget).attr('data-target'); diff --git a/Packages/ohif-core/client/components/base/mixins/link.js b/Packages/ohif-core/client/components/base/mixins/link.js new file mode 100644 index 000000000..5be855f44 --- /dev/null +++ b/Packages/ohif-core/client/components/base/mixins/link.js @@ -0,0 +1,26 @@ +import { OHIF } from 'meteor/ohif:core'; +import { Template } from 'meteor/templating'; + +/* + * link: controls a link + */ +OHIF.mixins.link = new OHIF.Mixin({ + dependencies: 'formItem', + composition: { + onRendered() { + const instance = Template.instance(); + const component = instance.component; + + // Set the element to be controlled + component.$element = instance.$('a:first'); + }, + + events: { + 'click a'(event, instance) { + if (instance.data.action) { + event.preventDefault(); + } + } + } + } +}); diff --git a/Packages/ohif-core/client/components/base/templates/link.html b/Packages/ohif-core/client/components/base/templates/link.html new file mode 100644 index 000000000..e08fac065 --- /dev/null +++ b/Packages/ohif-core/client/components/base/templates/link.html @@ -0,0 +1,11 @@ + diff --git a/Packages/ohif-core/client/components/bootstrap/dialog/form.html b/Packages/ohif-core/client/components/bootstrap/dialog/form.html index 235eec6e5..c396e7f3d 100644 --- a/Packages/ohif-core/client/components/bootstrap/dialog/form.html +++ b/Packages/ohif-core/client/components/bootstrap/dialog/form.html @@ -1,17 +1,19 @@