11454: On /search & /sessions page, check if the current user is
[arvados.git] / apps / workbench / app / assets / javascripts / components / edit_tags.js
index 6294bd1c4b6cf27b21c6b56f9f01beae5e3a7ae7..ac4d2df7b235f57851c80dae768d1da7fda3182f 100644 (file)
@@ -35,7 +35,9 @@ window.SelectOrAutocomplete = {
         vnode.state.awesomplete = new Awesomplete(vnode.dom, {
             list: vnode.attrs.options,
             minChars: 0,
+            maxItems: 1000000,
             autoFirst: true,
+            sort: false,
         })
         vnode.state.create = vnode.attrs.create
         vnode.state.options = vnode.attrs.options
@@ -176,23 +178,16 @@ window.TagEditorApp = {
         var tag = {name: m.stream(name), value: m.stream(value), rowKey: uniqueID++}
         vnode.state.tags.push(tag)
         // Set dirty flag when any of name/value changes to non empty string
-        tag.name.map(function(v) {
-            if (v !== '') {
-                vnode.state.dirty(true)
-            }
-        })
-        tag.value.map(function(v) {
-            if (v !== '') {
-                vnode.state.dirty(true)
-            }
-        })
+        tag.name.map(function() { vnode.state.dirty(true) })
+        tag.value.map(function() { vnode.state.dirty(true) })
         tag.name.map(m.redraw)
     },
     oninit: function(vnode) {
         vnode.state.sessionDB = new SessionDB()
         // Get vocabulary
         vnode.state.vocabulary = m.stream({"strict":false, "tags":{}})
-        m.request('/vocabulary.json').then(vnode.state.vocabulary)
+        var vocabularyTimestamp = parseInt(Date.now() / 300000) // Bust cache every 5 minutes
+        m.request('/vocabulary.json?v=' + vocabularyTimestamp).then(vnode.state.vocabulary)
         vnode.state.editMode = vnode.attrs.targetEditable
         vnode.state.tags = []
         vnode.state.dirty = m.stream(false)
@@ -213,6 +208,9 @@ window.TagEditorApp = {
                     Object.keys(o.properties).forEach(function(k) {
                         vnode.state.appendTag(vnode, k, o.properties[k])
                     })
+                    if (vnode.state.editMode) {
+                        vnode.state.appendTag(vnode, '', '')
+                    }
                     // Data synced with server, so dirty state should be false
                     vnode.state.dirty(false)
                     // Add new tag row when the last one is completed
@@ -238,7 +236,8 @@ window.TagEditorApp = {
                     onclick: function(e) {
                         var tags = {}
                         vnode.state.tags.forEach(function(t) {
-                            if (t.name() != '' && t.value() != '') {
+                            // Only ignore tags with empty key
+                            if (t.name() != '') {
                                 tags[t.name()] = t.value()
                             }
                         })