Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit 0e67b05

Browse files
author
Steven Morrison
committed
SM: Updated modal config - modal callback cant see Vue instance method.
1 parent f502740 commit 0e67b05

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

js/app.js

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,36 @@ var app = new Vue({
1212
storageKey: "zaffri-vuejs-task-manager",
1313
data: {
1414
newCategory: '',
15-
modalVisible: false,
16-
zaffriModal: {
15+
modalConfig: {
16+
// Modal visibility
17+
visible: false,
18+
19+
// type: notify || confirm
1720
type: "confirm",
21+
22+
// display data
1823
title: "Delete",
1924
messageBody: "Are you sure you want to delete this?",
2025
confirmText: "Confirm",
21-
cancelText: "Cancel", // for confirm modal type only
22-
action: {
26+
27+
// optional - for confirm modal type
28+
cancelText: "Cancel",
29+
callbackData: {
2330
type: null,
2431
index: 0,
2532
parentIndex: 0 // parentIndex for tasks (cat index)
33+
},
34+
confirmCallback: function(action, data) {
35+
36+
// Check action & handle callback data
37+
if(action) {
38+
if(data.type === "task-delete")
39+
this.deleteCategory(data);
40+
41+
if(data.type === "category-delete")
42+
this.deleteTask(data);
43+
}
44+
console.log("DATA: " + JSON.stringify(data));
2645
}
2746
},
2847
categories: [] // all app data
@@ -120,25 +139,25 @@ var app = new Vue({
120139
},
121140
showModal: function(index, type, parentIndex = null) { // parentIndex for tasks (cat index)
122141
// Modal action
123-
this.zaffriModal.action.type = type;
124-
this.zaffriModal.action.index = index;
125-
this.zaffriModal.action.parentIndex = parentIndex;
142+
this.modalConfig.callbackData.type = type;
143+
this.modalConfig.callbackData.index = index;
144+
this.modalConfig.callbackData.parentIndex = parentIndex;
126145
// Set visible
127-
this.modalVisible = true;
146+
this.modalConfig.visible = true;
128147
},
129148
hideModal: function(action) {
130-
this.modalVisible = false;
149+
// this.modalConfig.visible = false;
131150

132151
// if action = true (confirm clicked)
133-
if(action == true) {
152+
/*if(action == true) {
134153
var actionData = this.zaffriModal.action;
135154
// check action type
136155
if(actionData.type == "category-delete") {
137156
this.deleteCategory(actionData);
138157
} else {
139158
this.deleteTask(actionData);
140159
}
141-
}
160+
}*/
142161
}
143162
}
144163
});

0 commit comments

Comments
 (0)