1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
6 "strict": false, // Allow other tags not described here
10 "options": ["val1", "val2", "val3"],
11 "overridable": true // Allow value not listed in options
15 "options": ["val21", "val22", "val23"]
19 "options": ["val31", "val32", "val33"]
33 window.Vocabulary = function() {
38 // TODO: get the vocabulary file from http
41 getDef: function(tagName) {
42 if (tagName in v.data.types) {
43 return v.data.types[tagName]
45 return {"type": "text"} // Default
48 getTypes: function() {
49 return Object.keys(v.data.types)
54 window.Tags = function(db, uuid, objType) {
60 objPath: '/arvados/v1/' + objType + '/' + uuid,
61 tagIdx: 0, // Will use this as the tag access key
67 // Get the tag list from the API server
70 t.objPath).then(function(obj){
72 Object.keys(obj.properties).map(function(k) {
73 t.addTag(k, obj.properties[k])
83 data: {properties: JSON.stringify(t.getAll())}
88 // return hash to be POSTed to API server
90 Object.keys(t.data).map(function(k) {
92 tags[a_tag.name] = a_tag.value
96 addTag: function(name, value) {
105 removeTag: function(tagIdx) {
106 if (tagIdx in t.data) {
107 delete t.data[tagIdx]
110 getName: function(tagIdx) {
111 if (tagIdx in t.data) {
112 return t.data[tagIdx].name
115 get: function(tagIdx) {
116 if (tagIdx in t.data) {
117 return t.data[tagIdx]