func (d *ItemDatastore) datastoreKey(id uuid.UUID) *datastore.Key { return datastore.NewKey( d.context, kindItems, id.String(), 0, d.rootKey) }
func (v *HTMLView) addIDToItemTable(id uuid.UUID) { t := reflect.TypeOf((*models.ItemData)(nil)).Elem() document := js.Global.Get("document") table := document.Call("getElementById", "table_items") query := fmt.Sprintf("tr[data-%s=\"%s\"]", datasetAttrID, id.String()) if 1 <= table.Call("querySelectorAll", query).Length() { return } tr := document.Call("createElement", "tr") tr.Get("dataset").Set(toDatasetProp(datasetAttrID), id.String()) for i := 0; i < t.NumField(); i++ { f := t.Field(i) if f.Type == reflect.TypeOf((*models.Meta)(nil)).Elem() { continue } td := document.Call("createElement", "td") td.Get("dataset").Set(toDatasetProp(datasetAttrKey), f.Name) if isNumberType(f.Type) { td.Get("classList").Call("add", "number") } tr.Call("appendChild", td) } a := document.Call("createElement", "a") a.Set("textContent", "Delete") a.Call("setAttribute", "href", "") td := document.Call("createElement", "td") td.Call("appendChild", a) td.Get("classList").Call("add", "action") a.Set("onclick", async(v.onClickToDelete)) tr.Call("appendChild", td) tbody := table.Call("getElementsByTagName", "tbody").Index(0) tbody.Call("appendChild", tr) }
func (v *HTMLView) SetEditingItem(id uuid.UUID) { document := js.Global.Get("document") form := document.Call("getElementById", "form_item") form.Get("dataset").Set(toDatasetProp(datasetAttrID), id.String()) }