Skip to content

Commit

Permalink
Fixed: button loader in extend
Browse files Browse the repository at this point in the history
  • Loading branch information
we-vikram-wri231 committed Mar 13, 2024
1 parent 945ad7f commit 710d5f8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
15 changes: 9 additions & 6 deletions Vue/vaahtwo/stores/store-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ export const useModuleStore = defineStore({
*/
default:
options.method = 'PATCH';
options.callback_params = item.id;
ajax_url += '/'+item.id+'/action/'+type;
break;
}
Expand All @@ -433,7 +434,7 @@ export const useModuleStore = defineStore({
);
},
//---------------------------------------------------------------------
async itemActionAfter(data, res)
async itemActionAfter(data, res, item_id = null)
{
if(data)
{
Expand All @@ -446,14 +447,16 @@ export const useModuleStore = defineStore({
await root.reloadAssets();
await this.formActionAfter();
this.getItemMenu();
if(data.item){
await this.resetActivateBtnLoader(this.form.action,data.item);
}

}

if(item_id){
await this.resetActivateBtnLoader(this.form.action,item_id);
}
},
//---------------------------------------------------------------------
async resetActivateBtnLoader(action,item) {
let index = this.active_action.indexOf(action+'_'+item.id);
async resetActivateBtnLoader(action,item_id) {
let index = this.active_action.indexOf(action+'_'+item_id);
this.active_action.splice(index,1);
},
//---------------------------------------------------------------------
Expand Down
13 changes: 7 additions & 6 deletions Vue/vaahtwo/stores/store-themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ export const useThemeStore = defineStore({
*/
default:
options.method = 'PATCH';
options.callback_params = item.id;
ajax_url += '/'+item.id+'/action/'+type;
break;
}
Expand All @@ -433,7 +434,7 @@ export const useThemeStore = defineStore({
);
},
//---------------------------------------------------------------------
async itemActionAfter(data, res)
async itemActionAfter(data, res, item_id = null)
{
if (data)
{
Expand All @@ -444,10 +445,10 @@ export const useThemeStore = defineStore({
this.item = data;
await root.reloadAssets();
await this.formActionAfter();
if(data.item){
await this.resetActivateBtnLoader(this.form.action,data.item)
}
}

if(item_id){
await this.resetActivateBtnLoader(this.form.action,item_id);
}
},
//---------------------------------------------------------------------
Expand Down Expand Up @@ -489,8 +490,8 @@ export const useThemeStore = defineStore({
}
},
//---------------------------------------------------------------------
async resetActivateBtnLoader(action,item) {
let index = this.active_action.indexOf(action+'_'+item.id);
async resetActivateBtnLoader(action,item_id) {
let index = this.active_action.indexOf(action+'_'+item_id);
this.active_action.splice(index,1);
},
//---------------------------------------------------------------------
Expand Down
13 changes: 8 additions & 5 deletions Vue/vaahtwo/vaahvue/pinia/vaah.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const vaah = defineStore({
query: null,
headers: null,
show_success: true,
callback_params: null,
}
) {

Expand All @@ -33,7 +34,8 @@ export const vaah = defineStore({
method: 'get',
query: null,
headers: null,
show_toast: true,
show_success: true,
callback_params: null,
}

if(options)
Expand All @@ -48,7 +50,8 @@ export const vaah = defineStore({
let method = default_option.method.toLowerCase();
let query = default_option.query;
let headers = default_option.headers;
let show_toast = default_option.show_toast;
let show_success = default_option.show_success;
let callback_params = default_option.callback_params;



Expand Down Expand Up @@ -99,16 +102,16 @@ export const vaah = defineStore({
let ajax = await axios[method](url, params, q)
.then(function (response) {
self.show_progress_bar = false;
if(show_toast){
if(show_success){
self.processResponse(response);
}
if(callback)
{
if(response.data && response.data.data)
{
callback(response.data.data, response);
callback(response.data.data, response,callback_params);
} else{
callback(false, response);
callback(false, response,callback_params);
}
}
return response;
Expand Down

0 comments on commit 710d5f8

Please sign in to comment.