Skip to content

Commit b69a26a

Browse files
committed
add to frontend ability to add/remove tags, so we can use this in the code...
1 parent 09e637e commit b69a26a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/packages/frontend/account/actions.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,34 @@ export class AccountActions extends Actions<AccountState> {
244244
// @ts-ignore
245245
this.setState({ fragment });
246246
};
247+
248+
addTag = (tag: string) => {
249+
const store = this.redux.getStore("account");
250+
if (!store) return;
251+
const tags = store.get("tags");
252+
if (tags?.includes(tag)) {
253+
// already tagged
254+
return;
255+
}
256+
const table = this.redux.getTable("account");
257+
if (!table) return;
258+
const v = tags?.toJS() ?? [];
259+
v.push(tag);
260+
table.set({ tags: v });
261+
};
262+
263+
// delete won't be visible in frontend until a browser refresh...
264+
deleteTag = async (tag: string) => {
265+
const store = this.redux.getStore("account");
266+
if (!store) return;
267+
const tags = store.get("tags");
268+
if (!tags?.includes(tag)) {
269+
// already tagged
270+
return;
271+
}
272+
const table = this.redux.getTable("account");
273+
if (!table) return;
274+
const v = tags.toJS().filter((x) => x != tag);
275+
await webapp_client.async_query({ query: { accounts: { tags: v } } });
276+
};
247277
}

src/packages/frontend/account/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class AccountTable extends Table {
4747
ssh_keys: null,
4848
created: null,
4949
unlisted: null,
50-
//tags: null,
50+
tags: null,
5151
tours: null,
5252
purchase_closing_day: null,
5353
email_daily_statements: null,

0 commit comments

Comments
 (0)