mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
AddAddress option buttonType: component manage button in edit or create context
This commit is contained in:
parent
43f9e50100
commit
cdc6cf211a
@ -50,7 +50,6 @@ export default {
|
|||||||
create: window.buttonText || null,
|
create: window.buttonText || null,
|
||||||
edit: window.buttonText || null
|
edit: window.buttonText || null
|
||||||
},
|
},
|
||||||
type: window.buttonType || null,
|
|
||||||
size: window.buttonSize || null,
|
size: window.buttonSize || null,
|
||||||
displayText: window.buttonDisplayText //boolean, default: true
|
displayText: window.buttonDisplayText //boolean, default: true
|
||||||
},
|
},
|
||||||
|
@ -145,7 +145,7 @@ export default {
|
|||||||
default: {
|
default: {
|
||||||
button: {
|
button: {
|
||||||
text: { create: 'add_an_address_title', edit: 'edit_address' },
|
text: { create: 'add_an_address_title', edit: 'edit_address' },
|
||||||
type: 'btn-create',
|
type: { create: 'btn-create', edit: 'btn-update'},
|
||||||
displayText: true
|
displayText: true
|
||||||
},
|
},
|
||||||
title: { create: 'add_an_address_title', edit: 'edit_address' },
|
title: { create: 'add_an_address_title', edit: 'edit_address' },
|
||||||
@ -223,13 +223,10 @@ export default {
|
|||||||
return (this.context.edit) ? this.default.button.text.edit : this.default.button.text.create;
|
return (this.context.edit) ? this.default.button.text.edit : this.default.button.text.create;
|
||||||
},
|
},
|
||||||
getClassButton() {
|
getClassButton() {
|
||||||
let type = this.default.button.type,
|
let type = (this.context.edit) ? this.default.button.type.edit : this.default.button.type.create;
|
||||||
size = '';
|
let size = (typeof this.options.button !== 'undefined' && this.options.button.size !== null) ?
|
||||||
if (typeof this.options.button !== 'undefined') {
|
`${this.options.button.size} ` : '';
|
||||||
type = this.options.button.type !== null ? this.options.button.type : type;
|
return `${size}${type}`;
|
||||||
size = this.options.button.size !== null ? this.options.button.size : size;
|
|
||||||
}
|
|
||||||
return size ? `${size} ${type}` : type;
|
|
||||||
},
|
},
|
||||||
displayTextButton() {
|
displayTextButton() {
|
||||||
return (typeof this.options.button !== 'undefined' && typeof this.options.button.displayText !== 'undefined') ?
|
return (typeof this.options.button !== 'undefined' && typeof this.options.button.displayText !== 'undefined') ?
|
||||||
|
@ -3,8 +3,6 @@ import App from './App.vue';
|
|||||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
||||||
import { addressMessages } from './i18n';
|
import { addressMessages } from './i18n';
|
||||||
|
|
||||||
//import { createI18n } from 'vue-i18n';
|
|
||||||
//const i18n = createI18n();
|
|
||||||
const i18n = _createI18n( addressMessages );
|
const i18n = _createI18n( addressMessages );
|
||||||
|
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
|
@ -21,7 +21,7 @@ const getAccompanyingCourse = (id) => {
|
|||||||
* @body Object - dictionary with changes to post
|
* @body Object - dictionary with changes to post
|
||||||
*/
|
*/
|
||||||
const patchAccompanyingCourse = (id, body) => {
|
const patchAccompanyingCourse = (id, body) => {
|
||||||
console.log('body', body);
|
//console.log('body', body);
|
||||||
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
ref="addAddress">
|
ref="addAddress">
|
||||||
</add-address>
|
</add-address>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="isContextEdit && isPersonLocation">
|
<li v-if="isPersonLocation">
|
||||||
<button
|
<button
|
||||||
class="btn btn-remove"
|
class="btn btn-remove"
|
||||||
@click="removeAddress"
|
@click="removeAddress"
|
||||||
@ -112,10 +112,6 @@ export default {
|
|||||||
}
|
}
|
||||||
this.$store.commit('setAddressContext', context);
|
this.$store.commit('setAddressContext', context);
|
||||||
},
|
},
|
||||||
initAddressOptions() {
|
|
||||||
// here button.type is a contextual option
|
|
||||||
this.$refs.addAddress.$data.default.button.type = this.isContextEdit ? 'btn-update' : '';
|
|
||||||
},
|
|
||||||
removeAddress() {
|
removeAddress() {
|
||||||
console.log('remove address');
|
console.log('remove address');
|
||||||
let payload = {
|
let payload = {
|
||||||
@ -133,11 +129,11 @@ export default {
|
|||||||
let payload = this.$refs.addAddress.submitNewAddress();
|
let payload = this.$refs.addAddress.submitNewAddress();
|
||||||
payload['locationStatusTo'] = 'address'; // <== temporary, not none, not person
|
payload['locationStatusTo'] = 'address'; // <== temporary, not none, not person
|
||||||
this.$store.dispatch('updateLocation', payload);
|
this.$store.dispatch('updateLocation', payload);
|
||||||
|
this.$store.commit('setEditContextTrue');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initAddressContext();
|
this.initAddressContext();
|
||||||
this.initAddressOptions();
|
|
||||||
|
|
||||||
console.log('ac.locationStatus', this.accompanyingCourse.locationStatus);
|
console.log('ac.locationStatus', this.accompanyingCourse.locationStatus);
|
||||||
console.log('ac.location (temporary location)', this.accompanyingCourse.location);
|
console.log('ac.location (temporary location)', this.accompanyingCourse.location);
|
||||||
|
@ -104,6 +104,10 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
state.accompanyingCourse.location = r.location;
|
state.accompanyingCourse.location = r.location;
|
||||||
state.accompanyingCourse.locationStatus = r.locationStatus;
|
state.accompanyingCourse.locationStatus = r.locationStatus;
|
||||||
state.accompanyingCourse.personLocation = r.personLocation;
|
state.accompanyingCourse.personLocation = r.personLocation;
|
||||||
|
},
|
||||||
|
setEditContextTrue(state) {
|
||||||
|
console.log('### mutation: set edit context = true');
|
||||||
|
state.addressContext.edit = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -221,9 +225,8 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
resolve();
|
resolve();
|
||||||
})).catch((error) => { commit('catchError', error) });
|
})).catch((error) => { commit('catchError', error) });
|
||||||
},
|
},
|
||||||
/////
|
|
||||||
updateLocation({ commit }, payload) {
|
updateLocation({ commit }, payload) {
|
||||||
console.log('## action: updateLocation', payload);
|
console.log('## action: updateLocation', payload.locationStatusTo);
|
||||||
let body = { 'type': payload.entity, 'id': payload.entityId };
|
let body = { 'type': payload.entity, 'id': payload.entityId };
|
||||||
let location = {};
|
let location = {};
|
||||||
if (payload.locationStatusTo === 'person') { // patch for person address (don't remove addressLocation)
|
if (payload.locationStatusTo === 'person') { // patch for person address (don't remove addressLocation)
|
||||||
@ -246,7 +249,6 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
resolve();
|
resolve();
|
||||||
})).catch((error) => { commit('catchError', error) });
|
})).catch((error) => { commit('catchError', error) });
|
||||||
},
|
},
|
||||||
/////
|
|
||||||
confirmAccompanyingCourse({ commit }) {
|
confirmAccompanyingCourse({ commit }) {
|
||||||
//console.log('## action: confirmAccompanyingCourse');
|
//console.log('## action: confirmAccompanyingCourse');
|
||||||
confirmAccompanyingCourse(id)
|
confirmAccompanyingCourse(id)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<div class="accompanyingcourse-resume">
|
<div class="accompanyingcourse-resume">
|
||||||
|
|
||||||
{% if 'DRAFT' == accompanyingCourse.step %}
|
{% if 'DRAFT' == accompanyingCourse.step %}
|
||||||
<div class="col-8 alert alert-danger flash_message mb-5">
|
<div class="alert alert-danger flash_message mb-5">
|
||||||
<span>
|
<span>
|
||||||
{{ 'This accompanying course is still a draft'|trans }}
|
{{ 'This accompanying course is still a draft'|trans }}
|
||||||
<a href="{{ path('chill_person_accompanying_course_edit', { 'accompanying_period_id': accompanyingCourse.id } ) }}">
|
<a href="{{ path('chill_person_accompanying_course_edit', { 'accompanying_period_id': accompanyingCourse.id } ) }}">
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
* backUrl twig route: path('route', {parameters})
|
* backUrl twig route: path('route', {parameters})
|
||||||
* modalTitle twig translated chain
|
* modalTitle twig translated chain
|
||||||
* buttonText twig translated chain
|
* buttonText twig translated chain
|
||||||
* buttonType chill class like 'btn-update'
|
|
||||||
* buttonSize bootstrap class like 'btn-sm'
|
* buttonSize bootstrap class like 'btn-sm'
|
||||||
|
|
||||||
#}
|
#}
|
||||||
@ -52,10 +51,6 @@
|
|||||||
window.buttonText = '{{ buttonText|trans|e('js') }}';
|
window.buttonText = '{{ buttonText|trans|e('js') }}';
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if buttonType is defined %}
|
|
||||||
window.buttonType = '{{ buttonType|e('js') }}';
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if buttonSize is defined %}
|
{% if buttonSize is defined %}
|
||||||
window.buttonSize = '{{ buttonSize|e('js') }}';
|
window.buttonSize = '{{ buttonSize|e('js') }}';
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -206,7 +206,6 @@ This view should receive those arguments:
|
|||||||
address_id: person.lastAddress.id,
|
address_id: person.lastAddress.id,
|
||||||
backUrl: path('chill_person_view', { 'person_id': person.id }),
|
backUrl: path('chill_person_view', { 'person_id': person.id }),
|
||||||
modalTitle: 'Edit address', buttonText: 'Edit address',
|
modalTitle: 'Edit address', buttonText: 'Edit address',
|
||||||
buttonType: 'btn-update',
|
|
||||||
buttonSize: 'btn-sm',
|
buttonSize: 'btn-sm',
|
||||||
buttonDisplayText: false
|
buttonDisplayText: false
|
||||||
} %}
|
} %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user