keystone_ui-pages 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/keystone_ui/pages/manage/pages_controller.rb +1 -0
- data/app/models/keystone_ui/pages/page.rb +1 -1
- data/app/views/keystone_ui/pages/manage/pages/edit.html.erb +1 -1
- data/app/views/keystone_ui/pages/manage/pages/new.html.erb +7 -7
- data/lib/keystone_ui/pages/version.rb +1 -1
- data/lib/keystone_ui/pages.rb +19 -6
- data/the_local/agents/keystone_ui-pages-develop.md +15 -10
- data/the_local/interface.yml +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ebfd45f732eefa22bd08b4a5abd3c13ff88a2fa65c55a5309c89c8b21468c69c
|
|
4
|
+
data.tar.gz: bb309abcbff6e6d5a12aa1096db65c1a3d298ca1db781ed4c3110a5b4e6334a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 845983515d8a34e9d1c4ef3faff043e2ec832461b4fbf9be78b246d9fc9aba12c9823b69f3b573879df2755dd30e7041a7b1865939cab16d53ee1dad64f6a94e
|
|
7
|
+
data.tar.gz: dc35e48a37f83ed5b6e61d0d41b22e92139017c8b0fa9cb1cabb458e33bb61a69b38d625800a6f7f7113fe5f3ae80689691f5c2b4a2eafbef3f2db8753b3c4cf
|
|
@@ -89,7 +89,7 @@ module KeystoneUi
|
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
def default_name
|
|
92
|
-
word = KeystoneUi::Pages.
|
|
92
|
+
word = KeystoneUi::Pages.place_settings.dig(place, :default_name) || "Page"
|
|
93
93
|
used = Page.where(owner: owner, place: place).pluck(:name).filter_map { |taken| taken[/\A#{Regexp.escape(word)} (\d+)\z/, 1]&.to_i }
|
|
94
94
|
"#{word} #{(used.max || 0) + 1}"
|
|
95
95
|
end
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<label class="ks-label mb-1">Name</label>
|
|
10
10
|
<%= ui_input(name: "page[name]", value: @page.name) %>
|
|
11
11
|
|
|
12
|
-
<label class="ks-label mb-1">
|
|
12
|
+
<label class="ks-label mb-1">URL slug</label>
|
|
13
13
|
<%= ui_input(name: "page[slug]", value: @page.slug) %>
|
|
14
14
|
|
|
15
15
|
<% if KeystoneUi::Pages.places.any? %>
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
<%= hidden_field_tag "page[place]", @place if @place %>
|
|
6
6
|
|
|
7
7
|
<label class="ks-label mb-1">Name</label>
|
|
8
|
-
<%= ui_input(name: "page[name]", placeholder:
|
|
8
|
+
<%= ui_input(name: "page[name]", placeholder: @default_name) %>
|
|
9
9
|
|
|
10
|
-
<%
|
|
11
|
-
<label class="ks-label mb-1">
|
|
10
|
+
<% if KeystoneUi::Pages.slugged?(@place) %>
|
|
11
|
+
<label class="ks-label mb-1">URL slug</label>
|
|
12
12
|
<%= ui_input(name: "page[slug]", placeholder: "e.g. pricing") %>
|
|
13
|
+
<% end %>
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<% end %>
|
|
15
|
+
<% if !@place && KeystoneUi::Pages.places.any? %>
|
|
16
|
+
<label class="ks-label mb-1">Place</label>
|
|
17
|
+
<%= ui_select(name: "page[place]", options: KeystoneUi::Pages.places.invert.to_a) %>
|
|
18
18
|
<% end %>
|
|
19
19
|
|
|
20
20
|
<%= ui_button(label: "Create", type: :submit) %>
|
data/lib/keystone_ui/pages.rb
CHANGED
|
@@ -9,7 +9,7 @@ require "keystone_ui/pages/engine"
|
|
|
9
9
|
module KeystoneUi
|
|
10
10
|
module Pages
|
|
11
11
|
class << self
|
|
12
|
-
attr_writer :base_controller, :layout, :editor_layout, :pdf_stylesheet, :
|
|
12
|
+
attr_writer :base_controller, :layout, :editor_layout, :pdf_stylesheet, :access_exceptions
|
|
13
13
|
attr_accessor :edit_check_method, :view_check_method, :values_method, :owner_method, :refusal_method, :chrome_path
|
|
14
14
|
|
|
15
15
|
def base_controller
|
|
@@ -29,15 +29,28 @@ module KeystoneUi
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def places
|
|
32
|
-
@places || {}
|
|
32
|
+
(@places || {}).merge(place_settings.transform_values { |settings| settings[:label] })
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def
|
|
36
|
-
@
|
|
35
|
+
def places=(labels)
|
|
36
|
+
@places = labels
|
|
37
|
+
@place_settings = {}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def register_place(key, label:, default_name: "Page", slug: true)
|
|
41
|
+
place_settings[key.to_s] = { label: label, default_name: default_name, slug: slug }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def place_settings
|
|
45
|
+
@place_settings ||= {}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def slugged?(place)
|
|
49
|
+
place_settings.dig(place.to_s, :slug) != false
|
|
37
50
|
end
|
|
38
51
|
|
|
39
|
-
def
|
|
40
|
-
@
|
|
52
|
+
def access_exceptions
|
|
53
|
+
@access_exceptions || {}
|
|
41
54
|
end
|
|
42
55
|
end
|
|
43
56
|
|
|
@@ -51,11 +51,15 @@ inherit from the base controller, so define it there.
|
|
|
51
51
|
When it is not empty, the New page form offers them, a page with a place not
|
|
52
52
|
in it is refused, and the page list shows each page's place. The view check
|
|
53
53
|
reads it as `page.place`. Unset, pages have no place.
|
|
54
|
-
- `KeystoneUi::Pages.
|
|
55
|
-
—
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
- `KeystoneUi::Pages.register_place("client_report", label: "Client report", default_name: "Report template", slug: false)`
|
|
55
|
+
— adds one place with its own settings, so each part of a host app registers
|
|
56
|
+
the place it uses and two registrations never replace each other. `label:` is
|
|
57
|
+
what editors see. `default_name:` is the word a page created with no name
|
|
58
|
+
starts with, followed by the next number among that owner's pages in that
|
|
59
|
+
place, so "Report template 1", then "Report template 2"; it defaults to
|
|
60
|
+
"Page". `slug:` says whether the place's pages have a URL slug; it defaults to
|
|
61
|
+
true. Registered places are offered alongside any set with `places =`, and
|
|
62
|
+
`places = nil` clears both.
|
|
59
63
|
- `KeystoneUi::Pages.access_exceptions = { "public_preview" => "Public preview" }`
|
|
60
64
|
— a hash of the exceptions an editor can set on a page, each stored value to
|
|
61
65
|
its label. When it is not empty, the builder's top bar has an Access exception
|
|
@@ -324,11 +328,12 @@ The catalog offers these Keystone UI components by default: `button`,
|
|
|
324
328
|
restoring go to that place's list, and so does the builder's Back link unless
|
|
325
329
|
the host passed its own `return_to`.
|
|
326
330
|
- **The New page form** at `/pages/manage/pages/new` saves a blank name from
|
|
327
|
-
`
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
with the
|
|
331
|
+
the place's `default_name` and a blank slug as eight random hex characters,
|
|
332
|
+
and shows that name as the Name field's placeholder. A host linking to it
|
|
333
|
+
with `new_manage_page_path(place: "client_report")` creates the page in that
|
|
334
|
+
place and offers no place choice. The URL slug field shows unless the place
|
|
335
|
+
was registered with `slug: false`. A place the host does not name in the link
|
|
336
|
+
is ignored, and one posted to create is refused with the form shown again.
|
|
332
337
|
- **A page's settings** at `/pages/manage/pages/:id/edit` change its name, slug
|
|
333
338
|
and place after it is created. A slug another page of the same owner uses, or
|
|
334
339
|
a place the host does not name, is refused with a message and changes nothing.
|
data/the_local/interface.yml
CHANGED
|
@@ -11,7 +11,7 @@ develop:
|
|
|
11
11
|
- KeystoneUi::Pages.view_check_method
|
|
12
12
|
- KeystoneUi::Pages.places
|
|
13
13
|
- KeystoneUi::Pages.access_exceptions
|
|
14
|
-
- KeystoneUi::Pages.
|
|
14
|
+
- KeystoneUi::Pages.register_place
|
|
15
15
|
- KeystoneUi::Pages.values_method
|
|
16
16
|
- KeystoneUi::Pages.edit_check_method
|
|
17
17
|
- KeystoneUi::Pages.refusal_method
|