Jonathan Druart
1139972748
Test plan: = Koha = Apply the first patch, prove xt/vue_tidy.t and notice the failure Apply this patch, now it passes = QA test = Apply the change to the merge request linked with this qa-test-tools' issue: https://gitlab.com/koha-community/qa-test-tools/-/issues/62 inside your ktd container (at /kohadevbox/qa-test-tools/) Edit a .js within koha-tmpl/intranet-tmpl/prog/js/vue and a .ts file (cypress test) with something not pretty Commit and run the QA script => It's failing! Pretty the change, commit again, run the QA script => It's happy! = KTD - git hook = Go to the merge request linked with this ktd's issue: https://gitlab.com/koha-community/koha-testing-docker/-/issues/374 Copy the modified git hook to .git/hooks/ktd/pre-commit Edit a .js within koha-tmpl/intranet-tmpl/prog/js/vue and a .ts file (cypress test) with something not pretty Commit => Notice that the commit content is pretty! Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
102 lines
3 KiB
JavaScript
102 lines
3 KiB
JavaScript
import { defineStore } from "pinia";
|
|
|
|
export const useMainStore = defineStore("main", {
|
|
state: () => ({
|
|
_message: null,
|
|
_error: null,
|
|
_warning: null,
|
|
_confirmation: null,
|
|
_accept_callback: null,
|
|
previousMessage: null,
|
|
previousError: null,
|
|
displayed_already: false,
|
|
_is_submitting: false,
|
|
_is_loading: false,
|
|
}),
|
|
actions: {
|
|
setMessage(message, displayed = false) {
|
|
this._error = null;
|
|
this._warning = null;
|
|
this._message = message;
|
|
this._confirmation = null;
|
|
this.displayed_already =
|
|
displayed; /* Will be displayed on the next view */
|
|
},
|
|
setError(error, displayed = true) {
|
|
this._error = error;
|
|
this._warning = null;
|
|
this._message = null;
|
|
this._confirmation = null;
|
|
this.displayed_already =
|
|
displayed; /* Is displayed on the current view */
|
|
},
|
|
setWarning(warning, displayed = true) {
|
|
this._error = null;
|
|
this._warning = warning;
|
|
this._message = null;
|
|
this._confirmation = null;
|
|
this.displayed_already =
|
|
displayed; /* Is displayed on the current view */
|
|
},
|
|
setConfirmationDialog(confirmation, accept_callback, displayed = true) {
|
|
if (accept_callback) {
|
|
this._accept_callback = async () => {
|
|
await accept_callback();
|
|
this.removeConfirmationMessages();
|
|
};
|
|
}
|
|
this._confirmation = confirmation;
|
|
this.displayed_already =
|
|
displayed; /* Is displayed on the current view */
|
|
},
|
|
removeMessages() {
|
|
if (this.displayed_already) {
|
|
this._error = null;
|
|
this._warning = null;
|
|
this._message = null;
|
|
this._confirmation = null;
|
|
this._accept_callback = null;
|
|
}
|
|
this.displayed_already = true;
|
|
},
|
|
removeConfirmationMessages() {
|
|
this._confirmation = null;
|
|
this._accept_callback = null;
|
|
},
|
|
submitting() {
|
|
this._is_submitting = true;
|
|
},
|
|
submitted() {
|
|
this._is_submitting = false;
|
|
},
|
|
loading() {
|
|
this._is_loading = true;
|
|
},
|
|
loaded() {
|
|
this._is_loading = false;
|
|
},
|
|
},
|
|
getters: {
|
|
error() {
|
|
return this._error;
|
|
},
|
|
warning() {
|
|
return this._warning;
|
|
},
|
|
message() {
|
|
return this._message;
|
|
},
|
|
confirmation() {
|
|
return this._confirmation;
|
|
},
|
|
accept_callback() {
|
|
return this._accept_callback;
|
|
},
|
|
is_submitting() {
|
|
return this._is_submitting;
|
|
},
|
|
is_loading() {
|
|
return this._is_loading;
|
|
},
|
|
},
|
|
});
|