Refactor addTags/removeTags to Lib functions
This commit is contained in:
@@ -165,20 +165,13 @@
|
||||
(defCommand AddTags [entries (SelectedEntries 1 null)
|
||||
tagsToAdd (VarText null)]
|
||||
(doFor e entries
|
||||
(withWritableEntry archive e
|
||||
(if (hasComponent e Tags)
|
||||
(withWritableComponents archive e [tags Tags]
|
||||
(doFor tag tagsToAdd (dictSet tags tag 1)))
|
||||
(addComponent archive e Tags (for tag tagsToAdd =>tag 1)))))
|
||||
(addTags archive e tagsToAdd))
|
||||
entries) // TODO this includes entries that already had the tag in the changeset
|
||||
|
||||
(defCommand RemoveTags [entries (SelectedEntries 1 null)
|
||||
tagsToRemove (VarText null)]
|
||||
(doFor e entries
|
||||
(withWritableEntry archive e
|
||||
(when (hasComponent e Tags)
|
||||
(withWritableComponents archive e [tags Tags]
|
||||
(doFor tag tagsToRemove (tags.remove tag))))))
|
||||
(removeTags archive e tagsToRemove))
|
||||
entries) // TODO this includes entries that didn't have the tag in the changeset
|
||||
|
||||
(defCommand SelectByTags [tagsBoolExp (Text null)]
|
||||
|
@@ -51,13 +51,6 @@
|
||||
,@saveList
|
||||
,retValSymbol)))
|
||||
|
||||
(function addFile [:nat.Archive archive :nat.Entry e :String file &opt leaveOriginalCopy]
|
||||
(let [pathWithoutDir (haxe.io.Path.withoutDirectory file)]
|
||||
(unless !(= -1 (e.files.indexOf pathWithoutDir))
|
||||
((if leaveOriginalCopy sys.io.File.copy sys.FileSystem.rename)
|
||||
file (joinPath archive.archiveDir "files" pathWithoutDir))
|
||||
(e.files.push pathWithoutDir))))
|
||||
|
||||
(defMacro withWritableEntry [archive e &body body]
|
||||
(let [retValSymbol
|
||||
(symbol)]
|
||||
@@ -83,3 +76,23 @@
|
||||
|
||||
(function componentsMatch [:nat.Entry e componentsBoolExp]
|
||||
(BoolExpInterp.eval componentsBoolExp (for =>cType cId e.components cType)))
|
||||
|
||||
(function addFile [:nat.Archive archive :nat.Entry e :String file &opt leaveOriginalCopy]
|
||||
(withWritableEntry archive e
|
||||
(let [pathWithoutDir (haxe.io.Path.withoutDirectory file)]
|
||||
(unless !(= -1 (e.files.indexOf pathWithoutDir))
|
||||
((if leaveOriginalCopy sys.io.File.copy sys.FileSystem.rename)
|
||||
file (joinPath archive.archiveDir "files" pathWithoutDir))
|
||||
(e.files.push pathWithoutDir)))))
|
||||
|
||||
(function addTags [:nat.Archive archive :nat.Entry e :Array<String> tagsToAdd]
|
||||
(if (hasComponent e Tags)
|
||||
(withWritableComponents archive e [tags Tags]
|
||||
(doFor tag tagsToAdd (dictSet tags tag 1)))
|
||||
(addComponent archive e Tags (for tag tagsToAdd =>tag 1))))
|
||||
|
||||
(function removeTags [:nat.Archive archive :nat.Entry e :Array<String> tagsToRemove]
|
||||
(when (hasComponent e Tags)
|
||||
(withWritableComponents archive e [tags Tags]
|
||||
(doFor tag tagsToRemove (tags.remove tag)))))
|
||||
|
||||
|
Reference in New Issue
Block a user