Add toString to nat.Entry

This commit is contained in:
2022-10-08 22:33:41 +00:00
parent 18a81742fa
commit aa05960a67
2 changed files with 17 additions and 12 deletions

View File

@@ -47,7 +47,7 @@
(prop &mut :Entry->Dynamic defaultInitializer null) (prop &mut :Entry->Dynamic defaultInitializer null)
(method :Entry createEntry [:Entry->Dynamic initializer] // initializer returns Dynamic so ->:Void isn't required (method :Entry createEntry [:Entry->Dynamic initializer] // initializer returns Dynamic so ->:Void isn't required
(let [e (_newEntry)] (let [e (new Entry)]
(when defaultInitializer (when defaultInitializer
(defaultInitializer e)) (defaultInitializer e))
(initializer e) (initializer e)
@@ -73,11 +73,5 @@
(method fullString [:Entry e] (method fullString [:Entry e]
(haxe.Json.stringify e null "\t")) (haxe.Json.stringify e null "\t"))
(function :Entry _newEntry []
(object
id (Uuid.v4)
components (new Map)
files []))
(method filePath [file] (method filePath [file]
(joinPath archiveDir "files" file)) (joinPath archiveDir "files" file))

View File

@@ -1,7 +1,18 @@
package nat; package nat;
typedef Entry = { import uuid.Uuid;
id:String,
components:Map<String, String>, @:jsonParse(function (json) return new nat.Entry(json.id, json.components, json.files))
files:Array<FileRef> class Entry {
}; public var id:String;
public var components:Map<String, String> = [];
public var files:Array<FileRef> = [];
function toString() {
return if (components.exists("Name")) components["Name"] else 'entry $id';
}
public function new(?id:String, ?components:Map<String,String>, ?files:Array<String>) {
this.id = if (id != null) id else Uuid.v4();
if (components != null) this.components = components;
if (files != null) this.files = files;
}
}