Skip to content

Commit 0533070

Browse files
committed
Update SpreadJS version and add ViewProAppBase class
Bumped SpreadJS version from 17.1.0 to 18.2.0 in vp_fillStorage.4dm. Added handlerExportCsvSetting function and implemented ViewProAppBase class in custom-designer-functions.js to provide app-like methods and environment for designer functions.
1 parent 2ef4971 commit 0533070

File tree

2 files changed

+143
-2
lines changed

2 files changed

+143
-2
lines changed

Project/Sources/Methods/vp_fillStorage.4dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
$o.version:=1
55
$o.extension:=".4vp"
6-
$o.spreadJSVersion:="17.1.0"
6+
$o.spreadJSVersion:="18.2.0"
77
$o.options:=New shared object:C1526
88

99
Use ($o.options)

Resources/scripts/custom-designer-functions.js

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ customDesignerFunctions.fillWithTruncatedArraySystemFonts = function () {
122122
});
123123
};
124124

125+
customDesignerFunctions.handlerExportCsvSetting = function (setting) {
126+
var rowDelimiter = (setting.rowDelimiter || "\r");
127+
let columnDelimiter = setting.columnDelimiter || ",";
128+
setting.rowDelimiter = rowDelimiter.replace(/\\r/g, "\r").replace(/\\n/g, "\n").replace(/\\t/g, "\t");
129+
setting.columnDelimiter = columnDelimiter.replace(/\\r/g, '\r').replace(/\\n/g, '\n').replace(/\\t/g, '\t');
130+
};
131+
125132

126133
customDesignerFunctions.init = function () {
127134
/*
@@ -137,5 +144,139 @@ customDesignerFunctions.init = function () {
137144
*/
138145

139146
// add custom functions to the custom section of the insert function dialog
140-
vp_insertFunctionDialogTemplate.content[0].children[0].children[1].children[1].children[13].items = customDesignerFunctions.getCustomFunctionsList();
147+
148+
console.log("inject custom function in panel")
149+
150+
var InsertFunctionDialogTemplate = "insertFunctionDialogTemplate" // TemplateNames.InsertFunctionDialogTemplate
151+
var template = GC.Spread.Sheets.Designer.getTemplate(InsertFunctionDialogTemplate);
152+
const prop$8 = (o, o1) => `${o}.${o1}`;
153+
// TODO BETTER: inject new ones
154+
//template.content[0].children[0].children[1].children[1].children[12].items = customDesignerFunctions.getCustomFunctionsList();
155+
template.content[0].children[0].children[1].children[1].children.push({
156+
type: "List",
157+
visibleWhen: prop$8("functionDesc", "functionCategory") + "=14",
158+
bindingPath: prop$8("functionDesc", "customFunction"),
159+
items: customDesignerFunctions.getCustomFunctionsList(),
160+
keyboardSearch: true,
161+
dblClickSubmit: true
162+
});
163+
164+
// todo localize stuff here?
165+
GC.Spread.Sheets.Designer.registerTemplate("insertFunctionDialogTemplate", template);
141166
};
167+
168+
class ViewProAppBase {
169+
constructor() {
170+
this._ms = [ null, null, () => { return 0 }, () => {} ];
171+
}
172+
notifyReady() {
173+
customDesignerFunctions.notifyReady();
174+
}
175+
showOpenDialog(options) {
176+
return Promise.reject({
177+
status: "",
178+
fileName: ""
179+
});
180+
}
181+
open(fileName) {
182+
return {
183+
status: "",
184+
message: "",
185+
data: "",
186+
fileName: ""
187+
};
188+
}
189+
save(fileName, data2, isJSFile) {
190+
// customDesignerFunctions.saveAs
191+
return failed;
192+
}
193+
exit() {}
194+
importFile(fileName, options) {
195+
return Promise.resolve(failed);
196+
}
197+
showSaveDialog(options) {
198+
return cancelled;
199+
}
200+
exportFile(fileName, data2) {
201+
return Promise.resolve(failed);
202+
}
203+
needActive() {
204+
return true;
205+
}
206+
setClipboardData(data2) {}
207+
getClipboardText() {
208+
return "";
209+
}
210+
getBase64(fileName) {
211+
return "";
212+
}
213+
getClipboardHTML() {
214+
return "";
215+
}
216+
getSystemFonts() {
217+
return customDesignerFunctions.fillWithTruncatedArraySystemFonts();
218+
}
219+
closeAllWindows() {}
220+
setClipboardText(text) {}
221+
setClipboardHTML(string) {}
222+
getFileInfo(fullPath) {
223+
// dir, fileName
224+
return {};
225+
}
226+
joinPath(segments) {
227+
return segments && segments.toString();
228+
}
229+
config(name, value) {
230+
if (value === void 0) {
231+
return this.getConfig(name);
232+
} else {
233+
this.setConfig(name, value);
234+
return osEnv;
235+
}
236+
}
237+
getConfig(name) {
238+
this.initConfig(true);
239+
let path = name.split(".");
240+
let value = this._config;
241+
if (value) {
242+
for (let i = 0; i < path.length; i++) {
243+
let sub = value[path[i]];
244+
if (sub === void 0) {
245+
return void 0;
246+
}
247+
value = sub;
248+
}
249+
if (name === _createdDateKey) {
250+
let n = parseInt(value, 36);
251+
return isNaN(n) ? null : new Date(n);
252+
}
253+
return value;
254+
} else {
255+
return void 0;
256+
}
257+
}
258+
initConfig(onget) {
259+
if (this._config === void 0) {
260+
this._config = {};
261+
}
262+
}
263+
setConfig(name, value) {
264+
this.initConfig(false);
265+
let path = name.split(".");
266+
let item = this._config;
267+
if (item) {
268+
for (let i = 0; i < path.length - 1; i++) {
269+
let sub = item[path[i]];
270+
if (sub === void 0) {
271+
item[path[i]] = sub = {};
272+
}
273+
item = sub;
274+
}
275+
item[path[path.length - 1]] = value;
276+
}
277+
}
278+
restartApp() {}
279+
}
280+
281+
window.osenv = new ViewProAppBase();
282+
window.gc_native_app = true;

0 commit comments

Comments
 (0)