keystone_ui-pages 0.12.0 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bdb2a5e173156736e9f3afd765398eea7c1c6d0fabaf5035e50541aa371f95e
4
- data.tar.gz: e584a629e58788b5a134ad8ad543a478a063c9e3f34a384e6e19ad5c8f63a633
3
+ metadata.gz: c7e660c90fb7940307bee416e82c4a265af0a39d61c976ca4ac79d451e582100
4
+ data.tar.gz: 924ea703420c95dabe0fcad9baed0303ee92236532a8f94730a1672dea7ac268
5
5
  SHA512:
6
- metadata.gz: 208787e41cb9885aba3881701fd15a88df8fdd95ea8889a15c36bd7c11e561be0aeb0a64943d369de332aafe9999d2cd22e263260877c11c1a0fdee39ef1a1d4
7
- data.tar.gz: c03feea932a25b4d248382bebc3c5faf8c6ac9c5a5416ea6a07be00e696e8d1a2a80bf6cdaa979260a0e20ba3972048c44f17a91fac240922c8a9e611293310e
6
+ metadata.gz: d6423a67ac8e4c6dcca9f545be0595554ba542ecea798b482ccfe5b3ec04b680dff80884ea08d499264b78200300b661f4c2dd8039af98c8e0e9264d831d144f
7
+ data.tar.gz: 25c849878d32e676cffc59b712fe36a4b3104c22558ba2512eb921d628dad1f339feb069e098e72027e02c27ea28f79b100b127a8643beb3c43608f3bd8444cc
@@ -9,11 +9,12 @@ module KeystoneUi
9
9
 
10
10
  def new
11
11
  @default_name = Page.new(place: params[:place], owner: page_owner).default_name
12
+ @copyable_pages = copyable_pages
12
13
  end
13
14
 
14
15
  def create
15
16
  open_page = @sequence.pages.find { |page| page.id.to_s == params[:after_id].to_s }
16
- page = Page.create!(params.require(:page).permit(:name).merge(place: params[:place], sequence_key: params[:key], owner: page_owner))
17
+ page = Page.create!(params.require(:page).permit(:name).merge(place: params[:place], sequence_key: params[:key], owner: page_owner, **copied_document))
17
18
  send(KeystoneUi::Pages.place_settings.dig(params[:place], :adds_page_method), params[:key], page, open_page)
18
19
  redirect_to manage_sequence_path(params[:place], params[:key], page_id: page.id)
19
20
  end
@@ -42,6 +43,15 @@ module KeystoneUi
42
43
  refuse unless removes_page_method && @page
43
44
  end
44
45
 
46
+ def copyable_pages
47
+ owned_pages.current.where(place: params[:place])
48
+ end
49
+
50
+ def copied_document
51
+ source = copyable_pages.find_by(id: params[:copy_of_id]) if params[:copy_of_id].present?
52
+ source ? { document: source.document } : {}
53
+ end
54
+
45
55
  def removes_page_method
46
56
  KeystoneUi::Pages.place_settings.dig(params[:place], :removes_page_method)
47
57
  end
@@ -7,6 +7,9 @@
7
7
  <label class="ks-label mb-1">Name</label>
8
8
  <%= ui_input(name: "page[name]", placeholder: @default_name) %>
9
9
 
10
+ <label class="ks-label mb-1">Start from</label>
11
+ <%= ui_select(name: "copy_of_id", options: [ [ "Blank page", "" ] ] + @copyable_pages.map { |page| [ page.name, page.id ] }) %>
12
+
10
13
  <%= ui_button(label: "Create", type: :submit) %>
11
14
  <% end %>
12
15
  <% end %>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module KeystoneUi
4
4
  module Pages
5
- VERSION = "0.12.0"
5
+ VERSION = "0.13.0"
6
6
  end
7
7
  end
@@ -269,8 +269,12 @@ inherit from the base controller, so define it there.
269
269
  list has an Add page button, shown with or without pages in the sequence.
270
270
  - `/manage/sequences/:place/:key/pages/new` under the engine's mount path — the
271
271
  Add page form, or `keystone_ui_pages.new_manage_sequence_page_path("funnel", "abc123")`
272
- from the host. It runs behind the edit check and asks only for a name, with
273
- the place's next default name, such as "Step 3", as its placeholder. Creating
272
+ from the host. It runs behind the edit check and asks for a name, with
273
+ the place's next default name, such as "Step 3", as its placeholder, and for
274
+ Start from: Blank page, or a copy of any page in the same place that
275
+ `owner_method`'s record owns and that is not archived, including pages of
276
+ other sequences. A copy takes that page's document and nothing else, starts
277
+ as a draft, and changes apart from it afterwards. Creating
274
278
  makes a page with the name given, or the default name when it is left blank,
275
279
  in the sequence's place, with the sequence's key, owned by `owner_method`'s
276
280
  record, and with a random slug. The engine then calls the place's
@@ -80,7 +80,8 @@ Keystone UI itself must be installed first. Its own install local,
80
80
  key, which cannot be changed later.
81
81
  - **Adding a page to a sequence.** The sequence screen has an Add page button
82
82
  that asks for a name, with the place's default name used when it is left
83
- blank. The gem makes the page and tells the host which sequence it joins and
83
+ blank, and whether to start blank or as a copy of another page in the same
84
+ place. The gem makes the page and tells the host which sequence it joins and
84
85
  which page was open, so the host decides where it goes in the order. The new
85
86
  page then opens in the builder beside the list. A place that answers
86
87
  sequences must also handle pages added this way.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystone_ui-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider