diff --git a/app/javascript/components/PageCollectionCreationForm.js b/app/javascript/components/PageCollectionCreationForm.js deleted file mode 100644 index 8cf5ca87..00000000 --- a/app/javascript/components/PageCollectionCreationForm.js +++ /dev/null @@ -1,180 +0,0 @@ -/* - Usage: - <%= react_component("PageCollectionCreationForm", {}) %> -*/ - -import React from "react" -import PropTypes from "prop-types" - -import Stepper from '@material-ui/core/Stepper'; -import Step from '@material-ui/core/Step'; -import StepLabel from '@material-ui/core/StepLabel'; -import StepContent from '@material-ui/core/StepContent'; -import Button from '@material-ui/core/Button'; -import Paper from '@material-ui/core/Paper'; -import Typography from '@material-ui/core/Typography'; - -class PageCollectionCreationForm extends React.Component { - - constructor(props) { - super(props); - - this.state = { - active_step: 0 - } - - this.handleNext = this.handleNext.bind(this); - this.handleBack = this.handleBack.bind(this); - this.handleReset = this.handleReset.bind(this); - } - - handleNext() { - this.setState({ active_step: this.state.active_step + 1 }); - }; - - handleBack() { - this.setState({ active_step: this.state.active_step - 1 }); - }; - - handleReset() { - this.setState({ active_step: 0 }); - }; - - classIcon(class_name) { - return window.ContentTypeData[class_name].icon; - } - - classColor(class_name) { - return window.ContentTypeData[class_name].color; - } - - steps() { - return ['Basic information', 'Acceptable pages', 'Privacy settings']; - } - - getStepContent(step) { - switch (step) { - case 0: - return( -
- - Let's get started with some basic information. - -
- - -
-
- - -
-
- - -
-
-

Header image (optional)

-
-
- Upload - -
-
- -
-
-
- Supported file types: .png, .jpg, .jpeg, .gif -
-
-

-
- ); - case 1: - return ( -
- - Please check the types of pages you would like to allow in this collection. A small number of page types is recommended. - -
- {this.props.all_content_types.map(function(type) { - return( -

- -

- ); - })} - -
-
- ); - case 2: - return ( -
- - By default, all Collections are private. However, you can choose to make your Collection public at any time, and you can also choose to - accept submissions from other users! - -
- ); - - default: - return 'Unknown step'; - } - } - - render () { - return ( -
- - {this.steps().map((label, index) => ( - - {label} - - {this.getStepContent(index)} -
-
- - -
-
-
-
- ))} -
- {this.state.active_step === this.steps().length && ( - - All steps completed - you're finished! - - - )} -
- ); - } -} - -PageCollectionCreationForm.propTypes = { - document_id: PropTypes.number -}; - -export default PageCollectionCreationForm; \ No newline at end of file diff --git a/app/views/page_collections/_form.html.erb b/app/views/page_collections/_form.html.erb index 935b4563..77475661 100644 --- a/app/views/page_collections/_form.html.erb +++ b/app/views/page_collections/_form.html.erb @@ -9,7 +9,7 @@ inbox - Privacy & Submissions + Submissions +
- - + <%= f.label :title, class: 'block text-sm font-medium text-gray-700' %> + <%= f.text_field :title, placeholder: 'My Awesome Collection', class: 'mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-brown-500 focus:border-brown-500 sm:text-sm' %>
- - + <%= f.label :subtitle, class: 'block text-sm font-medium text-gray-700' %> + <%= f.text_field :subtitle, placeholder: 'My favorite pages', class: 'mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-brown-500 focus:border-brown-500 sm:text-sm' %>
- + <%= f.label :description, class: 'block text-sm font-medium text-gray-700' %>
- + <%= f.text_area :description, placeholder: "Write as little or as much as you'd like!", rows: 5, class: 'shadow-sm focus:ring-brown-500 focus:border-brown-500 mt-1 block w-full sm:text-sm border border-gray-300 rounded-md' %>
-

Brief description for your collection. <strong> and <em> tags are supported.

+

Brief description for your collection. <strong> and <em> tags are supported.

@@ -109,10 +121,10 @@
- + <%= f.file_field :header_image, class: 'sr-only' %> + <% end %>

to change your header

PNG, JPG, GIF up to 10MB

@@ -122,21 +134,21 @@
- Allowed page types -
+ +
+ <%# todo: show user's ACTIVATED page types here and put the others behind an "all types" expander %> <% Rails.application.config.content_types[:all].each do |content_type| %> -
-
- -
-
-
<% end %>
@@ -144,44 +156,32 @@
- + <%= f.submit 'Save', class: "#{PageCollection.color} border border-transparent rounded-md shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:bg-brown-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brown-500" %>
-

Privacy & Submissions

- You can always add pages to your own collections. + Collections are better with contributors!

-
Visibility

This setting controls who can see this collection.

-
- - -
-
- - -
-
- - -
+ <%= f.label :privacy, class: 'block' do %> + <%= f.radio_button :privacy, 'public', class: 'focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300' %> + Public - Visible to anyone browsing collections + <% end %> + <%= f.label :privacy, class: 'block' do %> + <%= f.radio_button :privacy, 'private', class: 'focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300' %> + Private - Visible only to you + <% end %>
@@ -189,33 +189,33 @@ Page submissions
-
- -
-
- -

Submissions are added to a review queue for you to approve or deny.

+
+ <%= f.label :allow_submissions, class: 'font-medium text-gray-700' do %> + <%= f.check_box :allow_submissions, class: 'mr-2 focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded' %> + Allow submissions from other users +

Submissions are added to a review queue for you to approve or deny.

+ <% end %>
-
+
-

- What kinds of pages are you looking for? This prompt will be shown to users who are about to submit a page. +

+ What kinds of pages are you looking for? Anything you write here will be shown to users who are about to submit a page.

-
- -
-
- -

Submissions will skip the review queue and automatically publish.

+
+ <%= f.label :auto_accept, class: 'font-medium text-gray-700' do %> + <%= f.check_box :auto_accept, class: 'mr-2 focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded' %> + Auto-accept all submissions +

Submissions will skip the review queue and automatically publish.

+ <% end %>
@@ -224,143 +224,8 @@
- + <%= f.submit 'Save', class: "#{PageCollection.color} border border-transparent rounded-md shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:bg-brown-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brown-500" %>
- - -
- - - - -<%# react_component("PageCollectionCreationForm", { - all_content_types: Rails.application.config.content_types[:all].map(&:name), - active_content_types: page_collection.page_types -}) %> - -<%= form_with(model: page_collection, local: true) do |f| %> - <% if page_collection.errors.any? %> -
-

<%= pluralize(page_collection.errors.count, "error") %> prohibited this Collection from being saved:

- -
    - <% page_collection.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
-
<% end %> - -
-
-
Basic information
- -
- <%= f.label :title %> - <%= f.text_field :title %> -
- -
- <%= f.label :subtitle %> - <%= f.text_field :subtitle %> -
- -
- <%= f.label :description %> - <%= f.text_field :description %> -
-
-
- -
-
-
Header image
- -
- -
-
- Upload - <%= f.file_field :header_image %> -
-
- -
-
-
- Supported file types: .png, .jpg, .jpeg, .gif -
-
- Don't forget to save your changes below for any new upload to take effect. -
-
-
-
- -
-
-
Acceptable pages
- -

- Please check the types of pages you'll allow to be submitted or added to this in this collection. A small number of page types is recommended. - You can change this at any time. -

-
- -
- <% Rails.application.config.content_types[:all].each do |content_type| %> -

- -

- <% end %> -
-
-
- -
-
-
Privacy & collaboration
- -
-
- -
-
- If you choose to make this collection public, you can also use the following controls: -
-
- -
- -
- -
- -
-
-
- -
- <%= f.submit nil, class: "btn #{PageCollection.color} white-text" %> -
-<% end %> +
diff --git a/app/views/page_collections/edit.html.erb b/app/views/page_collections/edit.html.erb index ee6d5aa0..54ec0eeb 100644 --- a/app/views/page_collections/edit.html.erb +++ b/app/views/page_collections/edit.html.erb @@ -6,10 +6,25 @@ <%= render 'form', page_collection: @page_collection %>
-<%= - link_to 'Delete this page collection', - @page_collection, - method: :DELETE, - class: 'btn btn-flat red-text right', - data: { confirm: "Are you sure? This will PERMANENTLY delete this entire collection! It cannot be undone!" } -%> \ No newline at end of file + +<%# todo maybe move this to a Danger Zone tab on the form, if persisted? %> +
+
+
+
+

Administrative actions

+

These actions are only shown to you, the owner.

+
+
+
+ <%= + link_to 'Permanently this page collection', + @page_collection, + method: :DELETE, + class: 'bg-red-500 px-4 py-2 text-white rounded', + data: { confirm: "Are you sure? This will PERMANENTLY delete this entire collection! It cannot be undone!" } + %> +
+
+
+