Refactor addTags/removeTags to Lib functions
This commit is contained in:
@@ -165,20 +165,13 @@
|
|||||||
(defCommand AddTags [entries (SelectedEntries 1 null)
|
(defCommand AddTags [entries (SelectedEntries 1 null)
|
||||||
tagsToAdd (VarText null)]
|
tagsToAdd (VarText null)]
|
||||||
(doFor e entries
|
(doFor e entries
|
||||||
(withWritableEntry archive e
|
(addTags archive e 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)))))
|
|
||||||
entries) // TODO this includes entries that already had the tag in the changeset
|
entries) // TODO this includes entries that already had the tag in the changeset
|
||||||
|
|
||||||
(defCommand RemoveTags [entries (SelectedEntries 1 null)
|
(defCommand RemoveTags [entries (SelectedEntries 1 null)
|
||||||
tagsToRemove (VarText null)]
|
tagsToRemove (VarText null)]
|
||||||
(doFor e entries
|
(doFor e entries
|
||||||
(withWritableEntry archive e
|
(removeTags archive e tagsToRemove))
|
||||||
(when (hasComponent e Tags)
|
|
||||||
(withWritableComponents archive e [tags Tags]
|
|
||||||
(doFor tag tagsToRemove (tags.remove tag))))))
|
|
||||||
entries) // TODO this includes entries that didn't have the tag in the changeset
|
entries) // TODO this includes entries that didn't have the tag in the changeset
|
||||||
|
|
||||||
(defCommand SelectByTags [tagsBoolExp (Text null)]
|
(defCommand SelectByTags [tagsBoolExp (Text null)]
|
||||||
|
|||||||
@@ -51,13 +51,6 @@
|
|||||||
,@saveList
|
,@saveList
|
||||||
,retValSymbol)))
|
,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]
|
(defMacro withWritableEntry [archive e &body body]
|
||||||
(let [retValSymbol
|
(let [retValSymbol
|
||||||
(symbol)]
|
(symbol)]
|
||||||
@@ -83,3 +76,23 @@
|
|||||||
|
|
||||||
(function componentsMatch [:nat.Entry e componentsBoolExp]
|
(function componentsMatch [:nat.Entry e componentsBoolExp]
|
||||||
(BoolExpInterp.eval componentsBoolExp (for =>cType cId e.components cType)))
|
(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