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.

Commit246b74e

Browse files
authored
refactor(tags): add optional icon (#427)
1 parentbb6fd46 commit246b74e

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

‎lib/groupher_server/cms/models/article_tag.ex‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule GroupherServer.CMS.Model.ArticleTag do
1111
aliasCMS.Model.{Author,Community}
1212

1313
@required_fields~w(thread title color author_id community_id)a
14-
@updatable_fields~w(thread title color community_id group extra)a
14+
@updatable_fields~w(thread title color community_id group extra icon)a
1515

1616
@typet::%ArticleTag{}
1717
schema"article_tags"do
@@ -20,6 +20,7 @@ defmodule GroupherServer.CMS.Model.ArticleTag do
2020
field(:thread,:string)
2121
field(:group,:string)
2222
field(:extra,{:array,:string})
23+
field(:icon,:string)
2324

2425
belongs_to(:community,Community)
2526
belongs_to(:author,Author)

‎lib/groupher_server_web/schema/cms/cms_types.ex‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
280280
field(:thread,:string)
281281
field(:group,:string)
282282
field(:extra,list_of(:string))
283+
field(:icon,:string)
283284

284285
field(:author,:user,resolve:dataloader(CMS,:author))
285286
field(:community,:community,resolve:dataloader(CMS,:community))

‎lib/groupher_server_web/schema/cms/mutations/community.ex‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
134134
arg(:group,:string)
135135
arg(:thread,:thread,default_value::post)
136136
arg(:extra,list_of(:string))
137+
arg(:icon,:string)
137138

138139
middleware(M.Authorize,:login)
139140
middleware(M.PassportLoader,source::community)
@@ -151,6 +152,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
151152
arg(:group,:string)
152153
arg(:thread,:thread,default_value::post)
153154
arg(:extra,list_of(:string))
155+
arg(:icon,:string)
154156

155157
middleware(M.Authorize,:login)
156158
middleware(M.PassportLoader,source::community)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmoduleGroupherServer.Repo.Migrations.AddIconToTagsdo
2+
useEcto.Migration
3+
4+
defchangedo
5+
altertable(:article_tags)do
6+
add(:icon,:string)
7+
end
8+
end
9+
end

‎test/groupher_server/cms/article_tags/post_tag_test.exs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ defmodule GroupherServer.Test.CMS.ArticleTag.PostTag do
2424
assertarticle_tag.group==article_tag_attrs.group
2525
end
2626

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

3132
assertarticle_tag.extra==["menuID","menuID2"]
33+
assertarticle_tag.icon=="icon addr"
3234
end
3335

3436
test"can update an article tag",~m(community article_tag_attrs user)ado

‎test/groupher_server_web/mutation/cms/article_tags/curd_test.exs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
101101
end
102102

103103
@update_tag_query"""
104-
mutation($id: ID!, $color: RainbowColor, $title: String, $communityId: ID!, $extra: [String]) {
105-
updateArticleTag(id: $id, color: $color, title: $title, communityId: $communityId, extra: $extra) {
104+
mutation($id: ID!, $color: RainbowColor, $title: String, $communityId: ID!, $extra: [String], $icon: String) {
105+
updateArticleTag(id: $id, color: $color, title: $title, communityId: $communityId, extra: $extra, icon: $icon) {
106106
id
107107
title
108108
color
109109
extra
110+
icon
110111
}
111112
}
112113
"""
@@ -119,7 +120,8 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
119120
color:"YELLOW",
120121
title:"new title",
121122
communityId:community.id,
122-
extra:["newMenuID"]
123+
extra:["newMenuID"],
124+
icon:"icon"
123125
}
124126

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

135138
@delete_tag_query"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp