Skip to content

Commit

Permalink
Fix tag's view_order updating
Browse files Browse the repository at this point in the history
  • Loading branch information
pijng committed Mar 15, 2024
1 parent 0daad27 commit c71c29b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ info:
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.6.1
version: 1.6.2
externalDocs:
description: Find out more about spec
url: ''
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/mongodb_adapter/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (s *TagStorage) DeleteTagByID(id int) error {
}

func (s *TagStorage) UpdateTagByID(id int, tag entities.Tag) (*entities.Tag, error) {
update := bson.M{"$set": bson.M{"name": tag.Name}}
update := bson.M{"$set": bson.M{"name": tag.Name, "view_order": tag.ViewOrder}}

_, err := s.collection.UpdateOne(s.ctx, bson.M{"id": id}, update)
if err != nil {
Expand Down
10 changes: 8 additions & 2 deletions web/src/shared/api/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ export const getTag = (id: number): Promise<TagResponse> => {
};

export const createTag = (tag: TagToCreate): Promise<TagResponse> => {
return post({ url: "/api/tags", body: JSON.stringify(tag) });
const view_order = tag.view_order === "" ? 0 : tag.view_order;
const modifiedTag: TagToCreate = { ...tag, view_order: view_order };

return post({ url: "/api/tags", body: JSON.stringify(modifiedTag) });
};

export const editTag = (tag: TagToUpdate): Promise<TagResponse> => {
return put({ url: `/api/tags/${tag.id}`, body: JSON.stringify(tag) });
const view_order = tag.view_order === "" ? 0 : tag.view_order;
const modifiedTag: TagToUpdate = { ...tag, view_order: view_order };

return put({ url: `/api/tags/${tag.id}`, body: JSON.stringify(modifiedTag) });
};

export const deleteTag = (id: number): Promise<TagResponse> => {
Expand Down
8 changes: 4 additions & 4 deletions web/src/widgets/schemas-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const SchemasList = () => {

list($sortedTags, ({ store: tag }) => {
h("div", () => {
spec({ classList: ["mt-2", "mb-9"] });
const $tagSchemas = combine(tag, $groupedTaggedSchemas, (t, schemas) => schemas[t.id]);

Subheader(remap(tag, "name"));
spec({ classList: ["mt-2", "mb-9"], visible: $tagSchemas.map((s) => s?.length > 0) });

const $tagSchemas = combine(tag, $groupedTaggedSchemas, (t, schemas) => schemas[t.id]);
Subheader(remap(tag, "name"));

h("div", () => {
spec({
Expand Down Expand Up @@ -48,7 +48,7 @@ export const SchemasList = () => {
});

h("div", () => {
spec({ classList: ["mt-2", "mb-9"] });
spec({ classList: ["mt-2", "mb-9"], visible: $generalSchemas.map((s) => s?.length > 0) });

Subheader(i18n("log_groups.general"));

Expand Down

0 comments on commit c71c29b

Please sign in to comment.