File tree 18 files changed +89
-2
lines changed
18 files changed +89
-2
lines changed Original file line number Diff line number Diff line change
1
+ {{ tag ({
2
+ label : __ (" posts.form.mp-channel.label" ),
3
+ items : publication .channels [property ].name
4
+ }) if property }}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import path from "node:path";
2
2
import { IndiekitError } from "@indiekit/error" ;
3
3
import { statusTypes } from "../status-types.js" ;
4
4
import {
5
+ getChannelItems ,
5
6
getGeoValue ,
6
7
getPostName ,
7
8
getPostProperties ,
@@ -26,6 +27,7 @@ export const postData = {
26
27
response . locals = {
27
28
accessToken : access_token ,
28
29
action : "create" ,
30
+ channelItems : getChannelItems ( publication ) ,
29
31
fields,
30
32
name,
31
33
postsPath : path . dirname ( request . baseUrl + request . path ) ,
@@ -68,6 +70,7 @@ export const postData = {
68
70
accessToken : access_token ,
69
71
action : action || "create" ,
70
72
allDay,
73
+ channelItems : getChannelItems ( publication ) ,
71
74
draftMode : scope ?. includes ( "draft" ) ,
72
75
fields,
73
76
geo,
Original file line number Diff line number Diff line change @@ -5,6 +5,18 @@ import formatcoords from "formatcoords";
5
5
import { endpoint } from "./endpoint.js" ;
6
6
import { statusTypes } from "./status-types.js" ;
7
7
8
+ /**
9
+ * Get channel `items` for checkboxes component
10
+ * @param {object } publication - Publication configuration
11
+ * @returns {object } Items for checkboxes component
12
+ */
13
+ export const getChannelItems = ( publication ) => {
14
+ return Object . entries ( publication . channels ) . map ( ( [ uid , channel ] ) => ( {
15
+ label : channel . name ,
16
+ value : uid ,
17
+ } ) ) ;
18
+ } ;
19
+
8
20
/**
9
21
* Get geographic coordinates property
10
22
* @param {string } geo - Latitude and longitude, comma separated
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Dateipfad oder URL"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Kanal"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " Slug"
63
66
},
Original file line number Diff line number Diff line change 86
86
"media" : {
87
87
"label" : " File path or URL"
88
88
},
89
+ "mp-channel" : {
90
+ "label" : " Channel"
91
+ },
89
92
"mp-slug" : {
90
93
"label" : " URL slug"
91
94
},
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Ruta o URL del archivo"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Canal"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " Babosa de URL"
63
66
},
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Ruta o URL del archivo"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Canal"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " URL slug"
63
66
},
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Chemin du fichier ou URL"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Canal"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " Identifiant unique d’URL (slug)"
63
66
},
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " फ़ाइल पथ या URL"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " चैनल"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " URL स्लग"
63
66
},
114
117
"title" : " %s पोस्ट अपडेट करें"
115
118
}
116
119
}
117
- }
120
+ }
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Jalur file atau URL"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Saluran"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " URL siput"
63
66
},
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Bestandspad of URL"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Kanaal"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " URL-slug"
63
66
},
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Ścieżka pliku lub adres URL"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Kanał"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " Ślimak URL"
63
66
},
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Caminho do arquivo ou URL"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Canal"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " Slug de URL"
63
66
},
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Putanja ili URL datoteke"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Kanal"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " URL slag"
63
66
},
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " Filsökväg eller URL"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " Kanal"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " URL-slug"
63
66
},
114
117
"title" : " Uppdatera %s inlägg"
115
118
}
116
119
}
117
- }
120
+ }
Original file line number Diff line number Diff line change 58
58
"media" : {
59
59
"label" : " 文件路径或 URL"
60
60
},
61
+ "mp-channel" : {
62
+ "label" : " 频道"
63
+ },
61
64
"mp-slug" : {
62
65
"label" : " 网址 slug"
63
66
},
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { strict as assert } from "node:assert";
2
2
import { describe , it } from "node:test" ;
3
3
import { mockResponse } from "mock-req-res" ;
4
4
import {
5
+ getChannelItems ,
5
6
getGeoProperty ,
6
7
getGeoValue ,
7
8
getLocationProperty ,
@@ -14,6 +15,14 @@ import {
14
15
15
16
const publication = {
16
17
me : "https://website.example" ,
18
+ channels : {
19
+ posts : {
20
+ name : "Posts" ,
21
+ } ,
22
+ pages : {
23
+ name : "Pages" ,
24
+ } ,
25
+ } ,
17
26
postTypes : {
18
27
article : {
19
28
name : "Journal entry" ,
@@ -43,6 +52,16 @@ const publication = {
43
52
} ;
44
53
45
54
describe ( "endpoint-posts/lib/utils" , ( ) => {
55
+ it ( "Gets channel `items` for checkboxes component" , ( ) => {
56
+ const result = getChannelItems ( publication ) ;
57
+
58
+ assert . equal ( result . length , 2 ) ;
59
+ assert . equal ( result [ 0 ] . label , "Posts" ) ;
60
+ assert . equal ( result [ 0 ] . value , "posts" ) ;
61
+ assert . equal ( result [ 1 ] . label , "Pages" ) ;
62
+ assert . equal ( result [ 1 ] . value , "pages" ) ;
63
+ } ) ;
64
+
46
65
it ( "Gets geographic coordinates property" , ( ) => {
47
66
assert . deepEqual ( getGeoProperty ( "50.8252, -0.1383" ) , {
48
67
type : "geo" ,
Original file line number Diff line number Diff line change 52
52
}]
53
53
}) }}
54
54
55
+ {{ checkboxes ({
56
+ name : " mp-channel" ,
57
+ values : properties [" mp-channel" ],
58
+ fieldset : {
59
+ legend : __ (" posts.form.mp-channel.label" ),
60
+ optional : true
61
+ },
62
+ items : channelItems
63
+ }) | indent (2) if publication .channels }}
64
+
55
65
{{ radios ({
56
66
inline : true ,
57
67
name : " visibility" ,
You can’t perform that action at this time.
0 commit comments