Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

refactor(tags): add optional icon#427

Merged
mydearxym merged 1 commit intodevfromadd-icon-to-tags
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletionlib/groupher_server/cms/models/article_tag.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@ defmodule GroupherServer.CMS.Model.ArticleTag do
alias CMS.Model.{Author, Community}

@required_fields ~w(thread title color author_id community_id)a
@updatable_fields ~w(thread title color community_id group extra)a
@updatable_fields ~w(thread title color community_id group extra icon)a

@type t :: %ArticleTag{}
schema "article_tags" do
Expand All@@ -20,6 +20,7 @@ defmodule GroupherServer.CMS.Model.ArticleTag do
field(:thread, :string)
field(:group, :string)
field(:extra, {:array, :string})
field(:icon, :string)

belongs_to(:community, Community)
belongs_to(:author, Author)
Expand Down
1 change: 1 addition & 0 deletionslib/groupher_server_web/schema/cms/cms_types.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,6 +280,7 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
field(:thread,:string)
field(:group,:string)
field(:extra,list_of(:string))
field(:icon,:string)

field(:author,:user,resolve:dataloader(CMS,:author))
field(:community,:community,resolve:dataloader(CMS,:community))
Expand Down
2 changes: 2 additions & 0 deletionslib/groupher_server_web/schema/cms/mutations/community.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -134,6 +134,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
arg(:group, :string)
arg(:thread, :thread, default_value: :post)
arg(:extra, list_of(:string))
arg(:icon, :string)

middleware(M.Authorize, :login)
middleware(M.PassportLoader, source: :community)
Expand All@@ -151,6 +152,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
arg(:group, :string)
arg(:thread, :thread, default_value: :post)
arg(:extra, list_of(:string))
arg(:icon, :string)

middleware(M.Authorize, :login)
middleware(M.PassportLoader, source: :community)
Expand Down
9 changes: 9 additions & 0 deletionspriv/repo/migrations/20210819055512_add_icon_to_tags.exs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
defmoduleGroupherServer.Repo.Migrations.AddIconToTagsdo
useEcto.Migration

defchangedo
altertable(:article_tags)do
add(:icon,:string)
end
end
end
6 changes: 4 additions & 2 deletionstest/groupher_server/cms/article_tags/post_tag_test.exs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,13 @@ defmodule GroupherServer.Test.CMS.ArticleTag.PostTag do
assertarticle_tag.group==article_tag_attrs.group
end

test"create article tag with extra data",~m(community article_tag_attrs user)ado
tag_attrs=Map.merge(article_tag_attrs,%{extra:["menuID","menuID2"]})
@tag:wip
test"create article tag with extra & icon data",~m(community article_tag_attrs user)ado
tag_attrs=Map.merge(article_tag_attrs,%{extra:["menuID","menuID2"],icon:"icon addr"})
{:ok,article_tag}=CMS.create_article_tag(community,:post,tag_attrs,user)

assertarticle_tag.extra==["menuID","menuID2"]
assertarticle_tag.icon=="icon addr"
end

test"can update an article tag",~m(community article_tag_attrs user)ado
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -101,12 +101,13 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
end

@update_tag_query"""
mutation($id: ID!, $color: RainbowColor, $title: String, $communityId: ID!, $extra: [String]) {
updateArticleTag(id: $id, color: $color, title: $title, communityId: $communityId, extra: $extra) {
mutation($id: ID!, $color: RainbowColor, $title: String, $communityId: ID!, $extra: [String], $icon: String) {
updateArticleTag(id: $id, color: $color, title: $title, communityId: $communityId, extra: $extra, icon: $icon) {
id
title
color
extra
icon
}
}
"""
Expand All@@ -119,7 +120,8 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
color:"YELLOW",
title:"new title",
communityId:community.id,
extra:["newMenuID"]
extra:["newMenuID"],
icon:"icon"
}

passport_rules=%{community.title=>%{"post.article_tag.update"=>true}}
Expand All@@ -130,6 +132,7 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
assertupdated["color"]=="YELLOW"
assertupdated["title"]=="new title"
assertupdated["extra"]==["newMenuID"]
assertupdated["icon"]=="icon"
end

@delete_tag_query"""
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp