Remove unnecessary savebutton vue component and create SaveButton Macro
This commit is contained in:
parent
02cc18a93f
commit
1aaf4421ab
@ -112,15 +112,11 @@ export default {
|
|||||||
validateAndOpenModal: function() {
|
validateAndOpenModal: function() {
|
||||||
let isValid = this.$children.reduce((previous, newVal) => {
|
let isValid = this.$children.reduce((previous, newVal) => {
|
||||||
// display textInput error if it is not valid
|
// display textInput error if it is not valid
|
||||||
if (newVal.$options.name == 'savebutton') {
|
if (!newVal.showValid) {
|
||||||
return true
|
newVal.showError = true
|
||||||
} else {
|
|
||||||
if (!newVal.showValid) {
|
|
||||||
newVal.showError = true
|
|
||||||
}
|
|
||||||
|
|
||||||
return newVal.showValid && previous
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return newVal.showValid && previous
|
||||||
}, true)
|
}, true)
|
||||||
this.validate()
|
this.validate()
|
||||||
isValid = this.errors.length == 0 && isValid
|
isValid = this.errors.length == 0 && isValid
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
export default {
|
|
||||||
name: 'savebutton',
|
|
||||||
|
|
||||||
props: {
|
|
||||||
text: String,
|
|
||||||
disabled: Boolean,
|
|
||||||
classes: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
data: function() {
|
|
||||||
return {
|
|
||||||
displayClasses: `usa-button usa-button-primary ${this.classes}`,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
template:
|
|
||||||
'<button type="submit" :class="displayClasses" tabindex="0" :disabled="disabled">{{ text }}</button>',
|
|
||||||
}
|
|
@ -33,7 +33,6 @@ import { isNotInVerticalViewport } from './lib/viewport'
|
|||||||
import DateSelector from './components/date_selector'
|
import DateSelector from './components/date_selector'
|
||||||
import SidenavToggler from './components/sidenav_toggler'
|
import SidenavToggler from './components/sidenav_toggler'
|
||||||
import KoReview from './components/forms/ko_review'
|
import KoReview from './components/forms/ko_review'
|
||||||
import savebutton from './components/save_button'
|
|
||||||
import BaseForm from './components/forms/base_form'
|
import BaseForm from './components/forms/base_form'
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
@ -70,7 +69,6 @@ const app = new Vue({
|
|||||||
EditOfficerForm,
|
EditOfficerForm,
|
||||||
SidenavToggler,
|
SidenavToggler,
|
||||||
KoReview,
|
KoReview,
|
||||||
savebutton,
|
|
||||||
BaseForm,
|
BaseForm,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import savebutton from '../components/save_button'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
this.$root.$on('field-change', this.handleFieldChange)
|
this.$root.$on('field-change', this.handleFieldChange)
|
||||||
@ -29,8 +27,4 @@ export default {
|
|||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
|
||||||
savebutton,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
6
templates/components/save_button.html
Normal file
6
templates/components/save_button.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{% macro SaveButton(text, additional_classes="") -%}
|
||||||
|
{% set class = "usa-button usa-button-primary" + additional_classes %}
|
||||||
|
<button type="submit" class="{{ class }}" tabindex="0" v-bind:disabled="disabled">
|
||||||
|
{{ text }}
|
||||||
|
</button>
|
||||||
|
{%- endmacro %}
|
@ -1,5 +1,6 @@
|
|||||||
{% from "components/icon.html" import Icon %}
|
{% from "components/icon.html" import Icon %}
|
||||||
{% from "components/options_input.html" import OptionsInput %}
|
{% from "components/options_input.html" import OptionsInput %}
|
||||||
|
{% from 'components/save_button.html' import SaveButton %}
|
||||||
|
|
||||||
{% from "components/modal.html" import Modal %}
|
{% from "components/modal.html" import Modal %}
|
||||||
{% from "components/alert.html" import Alert %}
|
{% from "components/alert.html" import Alert %}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
{% from "components/date_input.html" import DateInput %}
|
{% from "components/date_input.html" import DateInput %}
|
||||||
{% from "components/phone_input.html" import PhoneInput %}
|
{% from "components/phone_input.html" import PhoneInput %}
|
||||||
{% from "components/date_picker.html" import DatePicker %}
|
{% from "components/date_picker.html" import DatePicker %}
|
||||||
|
{% from 'components/save_button.html' import SaveButton %}
|
||||||
|
|
||||||
<base-form inline-template>
|
<base-form inline-template>
|
||||||
<form method="POST" action='{{ form_action }}'>
|
<form method="POST" action='{{ form_action }}'>
|
||||||
@ -34,11 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='action-group'>
|
<div class='action-group'>
|
||||||
<savebutton
|
{{ SaveButton(text=("fragments.edit_user_form.save_details_button" | translate), additional_classes="usa-button-big" )}}
|
||||||
text='{{ "fragments.edit_user_form.save_details_button" | translate }}'
|
|
||||||
classes="usa-button-big"
|
|
||||||
:disabled="disabled">
|
|
||||||
</savebutton>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</base-form>
|
</base-form>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
{% from "components/icon.html" import Icon %}
|
{% from "components/icon.html" import Icon %}
|
||||||
{% from "components/text_input.html" import TextInput %}
|
{% from "components/text_input.html" import TextInput %}
|
||||||
{% from "components/multi_step_modal_form.html" import MultiStepModalForm %}
|
{% from "components/multi_step_modal_form.html" import MultiStepModalForm %}
|
||||||
|
{% from 'components/save_button.html' import SaveButton %}
|
||||||
|
|
||||||
{% set secondary_breadcrumb = "navigation.portfolio_navigation.portfolio_admin" | translate %}
|
{% set secondary_breadcrumb = "navigation.portfolio_navigation.portfolio_admin" | translate %}
|
||||||
|
|
||||||
@ -24,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='edit-portfolio-name action-group'>
|
<div class='edit-portfolio-name action-group'>
|
||||||
<savebutton text="Save" classes="usa-button-big" :disabled="disabled"></savebutton>
|
{{ SaveButton(text='Save', additional_classes='usa-button-big') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='defense-row'>
|
<div class='defense-row'>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
{% from "components/icon.html" import Icon %}
|
{% from "components/icon.html" import Icon %}
|
||||||
{% from "components/modal.html" import Modal %}
|
{% from "components/modal.html" import Modal %}
|
||||||
{% from "components/text_input.html" import TextInput %}
|
{% from "components/text_input.html" import TextInput %}
|
||||||
|
{% from 'components/save_button.html' import SaveButton %}
|
||||||
|
|
||||||
{% set secondary_breadcrumb = 'portfolios.applications.new_application_title' | translate %}
|
{% set secondary_breadcrumb = 'portfolios.applications.new_application_title' | translate %}
|
||||||
|
|
||||||
@ -76,10 +77,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="action-group">
|
<div class="action-group">
|
||||||
<savebutton
|
{{ SaveButton(text=('portfolios.applications.create_button_text' | translate)) }}
|
||||||
text="{{ 'portfolios.applications.create_button_text' | translate }}"
|
|
||||||
:disabled="disabled">
|
|
||||||
</savebutton>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</new-application>
|
</new-application>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
{% from "components/icon.html" import Icon %}
|
{% from "components/icon.html" import Icon %}
|
||||||
{% from "components/text_input.html" import TextInput %}
|
{% from "components/text_input.html" import TextInput %}
|
||||||
{% from "components/confirmation_button.html" import ConfirmationButton %}
|
{% from "components/confirmation_button.html" import ConfirmationButton %}
|
||||||
|
{% from 'components/save_button.html' import SaveButton %}
|
||||||
|
|
||||||
|
|
||||||
{% macro Link(text, icon_name, onClick=None, url='#', classes='') %}
|
{% macro Link(text, icon_name, onClick=None, url='#', classes='') %}
|
||||||
@ -59,7 +60,7 @@
|
|||||||
{{ Icon("x") }}
|
{{ Icon("x") }}
|
||||||
<span>Cancel</span>
|
<span>Cancel</span>
|
||||||
</a>
|
</a>
|
||||||
<savebutton text="Save Changes" :disabled="disabled"></savebutton>
|
{{ SaveButton(text='Save Changes') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
{% from "components/alert.html" import Alert %}
|
{% from "components/alert.html" import Alert %}
|
||||||
{% from "components/review_field.html" import ReviewField %}
|
{% from "components/review_field.html" import ReviewField %}
|
||||||
{% from "components/upload_input.html" import UploadInput %}
|
{% from "components/upload_input.html" import UploadInput %}
|
||||||
|
{% from 'components/save_button.html' import SaveButton %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<ko-review inline-template v-bind:initial-data='{{ form.data|tojson }}'>
|
<ko-review inline-template v-bind:initial-data='{{ form.data|tojson }}'>
|
||||||
@ -103,7 +103,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<div class='action-group'>
|
<div class='action-group'>
|
||||||
<savebutton text="Continue" :disabled="disabled"></savebutton>
|
{{ SaveButton(text="Continue") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
{% from "components/text_input.html" import TextInput %}
|
{% from "components/text_input.html" import TextInput %}
|
||||||
{% from "components/multi_checkbox_input.html" import MultiCheckboxInput %}
|
{% from "components/multi_checkbox_input.html" import MultiCheckboxInput %}
|
||||||
|
{% from 'components/save_button.html' import SaveButton %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
@ -31,7 +32,7 @@
|
|||||||
{{ MultiCheckboxInput(form.required_distribution) }}
|
{{ MultiCheckboxInput(form.required_distribution) }}
|
||||||
|
|
||||||
<div class="action-group">
|
<div class="action-group">
|
||||||
<savebutton text="Continue" :disabled="disabled"></savebutton>
|
{{ SaveButton(text='Continue') }}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
{% from "components/text_input.html" import TextInput %}
|
{% from "components/text_input.html" import TextInput %}
|
||||||
{% from "components/checkbox_input.html" import CheckboxInput %}
|
{% from "components/checkbox_input.html" import CheckboxInput %}
|
||||||
{% from "components/icon.html" import Icon %}
|
{% from "components/icon.html" import Icon %}
|
||||||
|
{% from 'components/save_button.html' import SaveButton %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<base-form inline-template>
|
<base-form inline-template>
|
||||||
@ -38,7 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="action-group">
|
<div class="action-group">
|
||||||
<savebutton text="{{ 'common.sign' | translate }}" :disabled="disabled"></savebutton>
|
{{ SaveButton(text=('common.sign' | translate)) }}
|
||||||
<a
|
<a
|
||||||
href="{{ url_for("portfolios.ko_review", portfolio_id=portfolio_id, task_order_id=task_order_id) }}"
|
href="{{ url_for("portfolios.ko_review", portfolio_id=portfolio_id, task_order_id=task_order_id) }}"
|
||||||
class="action-group__action icon-link">
|
class="action-group__action icon-link">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user