|
11 | 11 |
|
12 | 12 | export default {
|
13 | 13 | name: 'SaveProjetComponent',
|
14 |
| - methods: { |
15 |
| - showSaveJSONDialog(){ |
16 |
| - remote.dialog.showSaveDialog({ |
17 |
| - title: 'Choose location to save JSON object in', |
18 |
| - defaultPath: remote.app.getPath('desktop'), |
19 |
| - message: 'Choose location to save JSON object in', |
20 |
| - nameFieldLabel: 'Application State Name', |
21 |
| - filters: [{ |
22 |
| - name: 'JSON Files', |
23 |
| - extensions: ['json'] |
24 |
| - }] |
25 |
| - }, |
26 |
| - result => { |
27 |
| - // event.sender.send('save-json-location', result); |
28 |
| - this.saveJSONLocation(result); |
29 |
| - }); |
30 |
| - }, |
31 |
| - parseFileName(file) { |
32 |
| - //'asdf/asdff/sdf.txt -> sdf.txt |
33 |
| - return file.split('/').pop(); |
34 |
| - }, |
35 |
| - parseAndDelete(htmlList) { |
36 |
| - htmlList.forEach(element => { |
37 |
| - if (element.children.length > 0) { |
38 |
| - console.log('in recurse'); |
39 |
| - this.parseAndDelete(element.children); |
40 |
| - } |
41 |
| - delete element._vm; |
42 |
| - delete element.parent; |
43 |
| - delete element.open; |
44 |
| - delete element.active; |
45 |
| - delete element.style; |
46 |
| - delete element.class; |
47 |
| - delete element.innerStyle; |
48 |
| - delete element.innerClass; |
49 |
| - delete element.innerBackStyle; |
50 |
| - delete element.innerBackClass; |
51 |
| - }); |
52 |
| - }, |
53 |
| - saveProjectJSON() { |
54 |
| - console.log('THIS ONE'); |
55 |
| - let projectLocation = this.$store.state.projects[ |
56 |
| - this.$store.state.activeTab |
57 |
| - ].lastSavedLocation; |
58 |
| - if (projectLocation) { |
59 |
| - console.log('IN SAVE LOCATION', this.$store.state); |
60 |
| - let state = this.$store.state; |
61 |
| - let routes = state.routes; |
62 |
| - for (let view in routes) { |
63 |
| - routes[view].forEach(component => { |
64 |
| - let htmlList = component.htmlList; |
65 |
| - this.parseAndDelete(htmlList); |
66 |
| - }); |
67 |
| - } |
68 |
| - let componentMap = this.$store.state.componentMap; |
69 |
| - console.log('compmap', componentMap); |
70 |
| - for (let component in componentMap) { |
71 |
| - if (componentMap[component].htmlList) { |
72 |
| - let comphtml = componentMap[component].htmlList; |
73 |
| - console.log('COMPHTML', comphtml); |
74 |
| - this.parseAndDelete(comphtml); |
75 |
| - } |
76 |
| - } |
| 14 | + // methods: { |
| 15 | + // showSaveJSONDialog(){ |
| 16 | + // remote.dialog.showSaveDialog({ |
| 17 | + // title: 'Choose location to save JSON object in', |
| 18 | + // defaultPath: remote.app.getPath('desktop'), |
| 19 | + // message: 'Choose location to save JSON object in', |
| 20 | + // nameFieldLabel: 'Application State Name', |
| 21 | + // filters: [{ |
| 22 | + // name: 'JSON Files', |
| 23 | + // extensions: ['json'] |
| 24 | + // }] |
| 25 | + // }, |
| 26 | + // result => { |
| 27 | + // // event.sender.send('save-json-location', result); |
| 28 | + // this.saveJSONLocation(result); |
| 29 | + // }); |
| 30 | + // }, |
| 31 | + // parseFileName(file) { |
| 32 | + // //'asdf/asdff/sdf.txt -> sdf.txt |
| 33 | + // return file.split('/').pop(); |
| 34 | + // }, |
| 35 | + // parseAndDelete(htmlList) { |
| 36 | + // htmlList.forEach(element => { |
| 37 | + // if (element.children.length > 0) { |
| 38 | + // console.log('in recurse'); |
| 39 | + // this.parseAndDelete(element.children); |
| 40 | + // } |
| 41 | + // delete element._vm; |
| 42 | + // delete element.parent; |
| 43 | + // delete element.open; |
| 44 | + // delete element.active; |
| 45 | + // delete element.style; |
| 46 | + // delete element.class; |
| 47 | + // delete element.innerStyle; |
| 48 | + // delete element.innerClass; |
| 49 | + // delete element.innerBackStyle; |
| 50 | + // delete element.innerBackClass; |
| 51 | + // }); |
| 52 | + // }, |
| 53 | + // saveProjectJSON() { |
| 54 | + // console.log('THIS ONE'); |
| 55 | + // let projectLocation = this.$store.state.projects[ |
| 56 | + // this.$store.state.activeTab |
| 57 | + // ].lastSavedLocation; |
| 58 | + // if (projectLocation) { |
| 59 | + // console.log('IN SAVE LOCATION', this.$store.state); |
| 60 | + // let state = this.$store.state; |
| 61 | + // let routes = state.routes; |
| 62 | + // for (let view in routes) { |
| 63 | + // routes[view].forEach(component => { |
| 64 | + // let htmlList = component.htmlList; |
| 65 | + // this.parseAndDelete(htmlList); |
| 66 | + // }); |
| 67 | + // } |
| 68 | + // let componentMap = this.$store.state.componentMap; |
| 69 | + // console.log('compmap', componentMap); |
| 70 | + // for (let component in componentMap) { |
| 71 | + // if (componentMap[component].htmlList) { |
| 72 | + // let comphtml = componentMap[component].htmlList; |
| 73 | + // console.log('COMPHTML', comphtml); |
| 74 | + // this.parseAndDelete(comphtml); |
| 75 | + // } |
| 76 | + // } |
77 | 77 |
|
78 |
| - fs.writeFileSync(projectLocation, JSON.stringify(state)); |
| 78 | + // fs.writeFileSync(projectLocation, JSON.stringify(state)); |
79 | 79 |
|
80 |
| - console.log('PROJECT SAVED TO LAST SAVED LOCATION'); |
81 |
| - } else { |
82 |
| - // ipc.send('show-save-json-dialog'); |
83 |
| - this.showSaveJSONDialog(); |
84 |
| - } |
85 |
| - }, |
86 |
| - saveJSONLocation(data){ |
87 |
| - //delete original key from local forage |
88 |
| - let deleteKey = this.$store.state.projects[this.$store.state.activeTab].filename; |
89 |
| - localforage |
90 |
| - .removeItem(deleteKey) |
91 |
| - .then(function() { |
92 |
| - console.log(deleteKey, 'Key is cleared!'); |
93 |
| - }) |
94 |
| - .catch(function(err) { |
95 |
| - console.log(err); |
96 |
| - }); |
| 80 | + // console.log('PROJECT SAVED TO LAST SAVED LOCATION'); |
| 81 | + // } else { |
| 82 | + // // ipc.send('show-save-json-dialog'); |
| 83 | + // this.showSaveJSONDialog(); |
| 84 | + // } |
| 85 | + // }, |
| 86 | + // saveJSONLocation(data){ |
| 87 | + // //delete original key from local forage |
| 88 | + // let deleteKey = this.$store.state.projects[this.$store.state.activeTab].filename; |
| 89 | + // localforage |
| 90 | + // .removeItem(deleteKey) |
| 91 | + // .then(function() { |
| 92 | + // console.log(deleteKey, 'Key is cleared!'); |
| 93 | + // }) |
| 94 | + // .catch(function(err) { |
| 95 | + // console.log(err); |
| 96 | + // }); |
97 | 97 |
|
98 |
| - let fileName = this.parseFileName(data); |
| 98 | + // let fileName = this.parseFileName(data); |
99 | 99 |
|
100 |
| - this.$set(this.$store.state.projects, this.$store.state.activeTab, { |
101 |
| - filename: fileName, |
102 |
| - lastSavedLocation: data |
103 |
| - }); |
104 |
| - let state = this.$store.state; |
105 |
| - let routes = state.routes; |
106 |
| - for (let view in routes) { |
107 |
| - routes[view].forEach(component => { |
108 |
| - let htmlList = component.htmlList; |
109 |
| - this.parseAndDelete(htmlList); |
110 |
| - }); |
111 |
| - } |
112 |
| - let componentMap = this.$store.state.componentMap; |
113 |
| - for (let component in componentMap) { |
114 |
| - if (component.htmlList) { |
115 |
| - let comphtml = component.htmlList; |
116 |
| - this.parseAndDelete(comphtml); |
117 |
| - } |
118 |
| - } |
| 100 | + // this.$set(this.$store.state.projects, this.$store.state.activeTab, { |
| 101 | + // filename: fileName, |
| 102 | + // lastSavedLocation: data |
| 103 | + // }); |
| 104 | + // let state = this.$store.state; |
| 105 | + // let routes = state.routes; |
| 106 | + // for (let view in routes) { |
| 107 | + // routes[view].forEach(component => { |
| 108 | + // let htmlList = component.htmlList; |
| 109 | + // this.parseAndDelete(htmlList); |
| 110 | + // }); |
| 111 | + // } |
| 112 | + // let componentMap = this.$store.state.componentMap; |
| 113 | + // for (let component in componentMap) { |
| 114 | + // if (component.htmlList) { |
| 115 | + // let comphtml = component.htmlList; |
| 116 | + // this.parseAndDelete(comphtml); |
| 117 | + // } |
| 118 | + // } |
119 | 119 |
|
120 |
| - fs.writeFileSync(data, JSON.stringify(state)); |
121 |
| - localforage |
122 |
| - .setItem(fileName, JSON.parse(fs.readFileSync(data, 'utf8'))) |
123 |
| - .then(result => { |
124 |
| - console.log('saved ', fileName, 'to local forage'); |
125 |
| - console.log('result is', result); |
126 |
| - }); |
127 |
| - console.log('PROJECT SAVED AS A JSON OBJECT!'); |
128 |
| - } |
129 |
| - }, |
130 |
| - created(){ |
131 |
| - Mousetrap.bind(['command+s', 'ctrl+s'], () => { |
132 |
| - this.saveProjectJSON() |
133 |
| - }) |
134 |
| - } |
| 120 | + // fs.writeFileSync(data, JSON.stringify(state)); |
| 121 | + // localforage |
| 122 | + // .setItem(fileName, JSON.parse(fs.readFileSync(data, 'utf8'))) |
| 123 | + // .then(result => { |
| 124 | + // console.log('saved ', fileName, 'to local forage'); |
| 125 | + // console.log('result is', result); |
| 126 | + // }); |
| 127 | + // console.log('PROJECT SAVED AS A JSON OBJECT!'); |
| 128 | + // } |
| 129 | + // }, |
| 130 | + // created(){ |
| 131 | + // Mousetrap.bind(['command+s', 'ctrl+s'], () => { |
| 132 | + // this.saveProjectJSON() |
| 133 | + // }) |
| 134 | + // } |
135 | 135 | }
|
136 | 136 | </script>
|
137 | 137 |
|
|
0 commit comments