riddler_admin 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/riddler_admin/application.js +0 -1
  3. data/app/assets/javascripts/riddler_admin/preview_contexts.js +2 -0
  4. data/app/assets/javascripts/riddler_admin/publish_requests.js +2 -0
  5. data/app/assets/javascripts/riddler_admin/steps.js +36 -22
  6. data/app/assets/stylesheets/riddler_admin/application.scss +3 -0
  7. data/app/assets/stylesheets/riddler_admin/preview_contexts.css +4 -0
  8. data/app/assets/stylesheets/riddler_admin/publish_requests.css +4 -0
  9. data/app/controllers/riddler_admin/application_controller.rb +24 -2
  10. data/app/controllers/riddler_admin/dashboard_controller.rb +8 -0
  11. data/app/controllers/riddler_admin/elements_controller.rb +6 -2
  12. data/app/controllers/riddler_admin/preview_contexts_controller.rb +60 -0
  13. data/app/controllers/riddler_admin/publish_requests_controller.rb +90 -0
  14. data/app/controllers/riddler_admin/slugs_controller.rb +67 -0
  15. data/app/controllers/riddler_admin/steps_controller.rb +73 -20
  16. data/app/helpers/riddler_admin/application_helper.rb +19 -0
  17. data/app/helpers/riddler_admin/preview_contexts_helper.rb +4 -0
  18. data/app/helpers/riddler_admin/publish_requests_helper.rb +4 -0
  19. data/app/models/riddler_admin/application_record.rb +4 -4
  20. data/app/models/riddler_admin/content_definition.rb +87 -0
  21. data/app/models/riddler_admin/element.rb +52 -10
  22. data/app/models/riddler_admin/elements/heading.rb +6 -0
  23. data/app/models/riddler_admin/elements/image.rb +18 -0
  24. data/app/models/riddler_admin/elements/link.rb +18 -0
  25. data/app/models/riddler_admin/elements/{copy.rb → text.rb} +7 -1
  26. data/app/models/riddler_admin/elements/variant.rb +19 -0
  27. data/app/models/riddler_admin/preview_context.rb +83 -0
  28. data/app/models/riddler_admin/publish_request.rb +57 -0
  29. data/app/models/riddler_admin/slug.rb +90 -0
  30. data/app/models/riddler_admin/step.rb +66 -4
  31. data/app/models/riddler_admin/steps/variant.rb +19 -0
  32. data/app/validators/parseable_predicate_validator.rb +8 -0
  33. data/app/views/layouts/riddler_admin/application.html.erb +11 -4
  34. data/app/views/riddler_admin/_element.html.erb +14 -10
  35. data/app/views/riddler_admin/_element_container.html.erb +11 -0
  36. data/app/views/riddler_admin/_navbar.html.erb +29 -0
  37. data/app/views/riddler_admin/_preview_step.html.erb +39 -0
  38. data/app/views/riddler_admin/_step.html.erb +35 -0
  39. data/app/views/riddler_admin/_step_container.html.erb +11 -0
  40. data/app/views/riddler_admin/dashboard/index.html.erb +44 -0
  41. data/app/views/riddler_admin/elements/_form.html.erb +37 -0
  42. data/app/views/riddler_admin/elements/_new.html.erb +41 -8
  43. data/app/views/riddler_admin/elements/_show.html.erb +3 -1
  44. data/app/views/riddler_admin/elements/edit.js.erb +2 -0
  45. data/app/views/riddler_admin/elements/heading/_detail.html.erb +0 -0
  46. data/app/views/riddler_admin/elements/heading/_form.html.erb +8 -2
  47. data/app/views/riddler_admin/elements/image/_detail.html.erb +0 -0
  48. data/app/views/riddler_admin/elements/image/_form.html.erb +12 -0
  49. data/app/views/riddler_admin/elements/link/_detail.html.erb +0 -0
  50. data/app/views/riddler_admin/elements/link/_form.html.erb +12 -0
  51. data/app/views/riddler_admin/elements/show.js.erb +2 -2
  52. data/app/views/riddler_admin/elements/text/_detail.html.erb +0 -0
  53. data/app/views/riddler_admin/elements/text/_form.html.erb +4 -0
  54. data/app/views/riddler_admin/elements/variant/_detail.html.erb +6 -0
  55. data/app/views/riddler_admin/elements/variant/_form.html.erb +1 -0
  56. data/app/views/riddler_admin/preview_contexts/_form.html.erb +44 -0
  57. data/app/views/riddler_admin/preview_contexts/edit.html.erb +10 -0
  58. data/app/views/riddler_admin/preview_contexts/index.html.erb +43 -0
  59. data/app/views/riddler_admin/preview_contexts/new.html.erb +10 -0
  60. data/app/views/riddler_admin/preview_contexts/show.html.erb +45 -0
  61. data/app/views/riddler_admin/publish_requests/_actions.html.erb +19 -0
  62. data/app/views/riddler_admin/publish_requests/_form.html.erb +53 -0
  63. data/app/views/riddler_admin/publish_requests/approve.js.erb +2 -0
  64. data/app/views/riddler_admin/publish_requests/edit.html.erb +10 -0
  65. data/app/views/riddler_admin/publish_requests/index.html.erb +62 -0
  66. data/app/views/riddler_admin/publish_requests/new.html.erb +10 -0
  67. data/app/views/riddler_admin/publish_requests/publish.js.erb +2 -0
  68. data/app/views/riddler_admin/publish_requests/show.html.erb +25 -0
  69. data/app/views/riddler_admin/slugs/_form.html.erb +48 -0
  70. data/app/views/riddler_admin/slugs/edit.html.erb +10 -0
  71. data/app/views/riddler_admin/slugs/index.html.erb +44 -0
  72. data/app/views/riddler_admin/slugs/new.html.erb +10 -0
  73. data/app/views/riddler_admin/slugs/show.html.erb +18 -0
  74. data/app/views/riddler_admin/steps/_definition.html.erb +11 -0
  75. data/app/views/riddler_admin/steps/_form.html.erb +45 -17
  76. data/app/views/riddler_admin/steps/_new_sub_step.html.erb +56 -0
  77. data/app/views/riddler_admin/steps/_visual_preview.html.erb +24 -0
  78. data/app/views/riddler_admin/steps/content/_show.html.erb +53 -25
  79. data/app/views/riddler_admin/steps/edit.html.erb +15 -4
  80. data/app/views/riddler_admin/steps/index.html.erb +24 -10
  81. data/app/views/riddler_admin/steps/internal_preview.js.erb +5 -0
  82. data/app/views/riddler_admin/steps/new.html.erb +10 -5
  83. data/app/views/riddler_admin/steps/new.js.erb +3 -0
  84. data/app/views/riddler_admin/steps/preview.json.erb +1 -0
  85. data/app/views/riddler_admin/steps/show.html.erb +26 -11
  86. data/app/views/riddler_admin/steps/show.js.erb +4 -0
  87. data/app/views/riddler_admin/steps/variant/_show.html.erb +59 -0
  88. data/config/routes.rb +20 -1
  89. data/db/migrate/20181124201519_riddler_admin_genesis.rb +72 -0
  90. data/lib/riddler_admin.rb +29 -2
  91. data/lib/riddler_admin/configuration.rb +44 -0
  92. data/lib/riddler_admin/version.rb +1 -1
  93. metadata +75 -30
  94. data/app/views/riddler_admin/elements/copy/_class.html.erb +0 -3
  95. data/app/views/riddler_admin/elements/copy/_form.html.erb +0 -2
  96. data/app/views/riddler_admin/elements/heading/_class.html.erb +0 -3
  97. data/app/views/riddler_admin/steps/_preview.html.erb +0 -5
  98. data/db/migrate/20181124201519_create_riddler_admin_steps.rb +0 -20
@@ -0,0 +1,37 @@
1
+ <%= form_with model: element do |f| %>
2
+ <% if element.errors.any? %>
3
+ <div>
4
+ <h4><%= pluralize(element.errors.count, "error") %> prohibited this element from being saved:</h4>
5
+
6
+ <ul>
7
+ <% element.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="form-row">
15
+ <div class="form-group col">
16
+ <%= f.label :name %>
17
+ <%= f.text_field :name, class: 'form-control' %>
18
+ <small class="form-text text-muted">Cannot start with a capital letter or a number. Clients can use this for custom rendering.</small>
19
+ </div>
20
+
21
+ <div class="form-group col">
22
+ <%= f.label :include_predicate %>
23
+ <%= f.text_field :include_predicate, class: "form-control", placeholder: "e.g. params.user_id is present" %>
24
+ <small class="form-text text-muted">Use data from the context that evaluates to <code>true</code> or <code>false</code></small>
25
+ </div>
26
+ </div>
27
+
28
+ <%= render partial: element.to_partial_path("form"), locals: { f: f, element: element } %>
29
+
30
+ <div class="form-row">
31
+ <div class="form-group col">
32
+ <%= f.submit 'Update element', class: 'btn btn-outline-primary' %>
33
+ <%= link_to "Delete", element, method: :delete, remote: true, data: { confirm: "Are you sure?" }, class: 'btn btn-link' %>
34
+ </div>
35
+ </div>
36
+
37
+ <% end %>
@@ -1,15 +1,48 @@
1
1
  <%= form_with model: @element do |f| %>
2
- <h5>New Element</h5>
3
2
  <% if @element.errors.any? %>
4
- ERRORS
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@element.errors.count, "error") %> prohibited this step from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @element.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
5
12
  <% end %>
6
13
 
7
- <%= f.hidden_field :id %>
8
- <%= f.hidden_field :type %>
9
- <%= f.hidden_field :container_type %>
10
- <%= f.hidden_field :container_id %>
14
+ <div class="card" style="margin-bottom: 32px;">
15
+ <div class="card-body">
16
+
17
+ <div class="card-title">
18
+ <h5>New <%= @element.short_name %> Element</h5>
19
+ </div>
20
+
21
+ <%= f.hidden_field :id %>
22
+ <%= f.hidden_field :type %>
23
+ <%= f.hidden_field :container_type %>
24
+ <%= f.hidden_field :container_id %>
25
+
26
+ <div class="form-group">
27
+ <div class="form-row">
28
+ <div class="col">
29
+ <%= f.label :name %>
30
+ <%= f.text_field :name, class: 'form-control' %>
31
+ <small class="form-text text-muted">Cannot start with a capital letter or a number. Clients can use this for custom rendering.</small>
32
+ </div>
33
+
34
+ <div class="col">
35
+ <%= f.label :include_predicate %>
36
+ <%= f.text_field :include_predicate, class: "form-control", placeholder: "e.g. params.user_id is present" %>
37
+ <small class="form-text text-muted">Use data from the context that evaluates to <code>true</code> or <code>false</code></small>
38
+ </div>
39
+ </div>
11
40
 
12
- <%= render partial: "#{@element.to_partial_path}/form", locals: { f: f } %>
41
+ <%= render partial: "#{@element.to_partial_path}/form", locals: { f: f, element: @element } %>
13
42
 
14
- <%= f.submit %>
43
+ <%= f.submit 'Add element', class: 'btn btn-primary' %>
44
+ </div>
45
+ </div>
46
+ </div>
15
47
  <% end %>
48
+ </div>
@@ -1,4 +1,3 @@
1
- <%- binding.pry %>
2
1
  <div id="<%= element.id %>">
3
2
  <%= form_with model: element, data: { "new-element-form" => true } do |f| %>
4
3
  <h5>Element</h5>
@@ -11,6 +10,9 @@
11
10
  <%= f.hidden_field :container_type %>
12
11
  <%= f.hidden_field :container_id %>
13
12
 
13
+ <%= f.label :name %>
14
+ <%= f.text_field :name %>
15
+
14
16
  <%= render partial: "#{element.to_partial_path}/form", locals: { f: f } %>
15
17
 
16
18
  <%= f.submit %>
@@ -0,0 +1,2 @@
1
+ $("#<%= @element.id %>-form")
2
+ .html("<%= j render partial: "riddler_admin/elements/form", locals: { element: @element } %>")
@@ -1,2 +1,8 @@
1
- <%= f.label :text %>
2
- <%= f.text_field :text %>
1
+ <div class="form-group">
2
+ <div class="form-row">
3
+ <div class="col">
4
+ <%= f.label :text %>
5
+ <%= f.text_field :text, class: 'form-control' %>
6
+ </div>
7
+ </div>
8
+ </div>
@@ -0,0 +1,12 @@
1
+ <div class="form-group">
2
+ <div class="form-row">
3
+ <div class="col">
4
+ <%= f.label :text, "Alt text" %>
5
+ <%= f.text_field :text, class: "form-control" %>
6
+ </div>
7
+ <div class="col">
8
+ <%= f.label :url, "Src" %>
9
+ <%= f.text_field :url, class: "form-control" %>
10
+ </div>
11
+ </div>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <div class="form-group">
2
+ <div class="form-row">
3
+ <div class="col">
4
+ <%= f.label :text, "Link text" %>
5
+ <%= f.text_field :text, class: "form-control" %>
6
+ </div>
7
+ <div class="col">
8
+ <%= f.label :url, "Href" %>
9
+ <%= f.text_field :url, class: "form-control" %>
10
+ </div>
11
+ </div>
12
+ </div>
@@ -1,4 +1,4 @@
1
1
  $("#new-element").fadeOut().html("").show();
2
2
 
3
- $("#step-elements")
4
- .html("<%= j render partial: "riddler_admin/element", collection: @element.container.elements %>")
3
+ $("#<%= @element.step.id %>-elements")
4
+ .html("<%= j render partial: "riddler_admin/element", collection: @element.step.elements %>")
@@ -0,0 +1,4 @@
1
+ <div class="form-group">
2
+ <%= f.label :text %>
3
+ <%= f.text_area :text, class: 'form-control', rows: "5" %>
4
+ </div>
@@ -0,0 +1,6 @@
1
+ Add new:
2
+ <% RiddlerAdmin::Element.available_classes.each do |klass| %>
3
+ <%= link_to "#{klass.short_name}", new_element_path(type: klass.name, element_id: element.id), remote: true, class: "btn btn-outline-secondary btn-sm" %>
4
+ <% end %>
5
+
6
+ <%= render partial: "riddler_admin/element_container", locals: { container: element } %>
@@ -0,0 +1 @@
1
+ <div class="form-group"></div>
@@ -0,0 +1,44 @@
1
+ <%= form_with model: preview_context, local: true do |form| %>
2
+ <div class="row">
3
+ <% if preview_context.errors.any? %>
4
+ <div id="error_explanation">
5
+ <h2><%= pluralize(preview_context.errors.count, "error") %> prohibited this preview context from being saved:</h2>
6
+
7
+ <ul>
8
+ <% preview_context.errors.full_messages.each do |message| %>
9
+ <li><%= message %></li>
10
+ <% end %>
11
+ </ul>
12
+ </div>
13
+ <% end %>
14
+ </div>
15
+
16
+ <div class="row">
17
+ <div class="col">
18
+ <div class="form-group">
19
+ <div class="field">
20
+ <%= form.label :title %>
21
+ <%= form.text_field :title, class:"form-control" %>
22
+ </div>
23
+ </div>
24
+ <div class="form-group">
25
+ <div class="field">
26
+ <%= form.label :params %>
27
+ <%= form.text_area :params, class:"form-control", rows: 3, placeholder: "e.g. user_id: 1" %>
28
+ </div>
29
+ </div>
30
+ <div class="form-group">
31
+ <div class="field">
32
+ <%= form.label :headers %>
33
+ <%= form.text_area :headers, class:"form-control", rows: 3, placeholder: "e.g. authorization: [JWT GOES HERE]" %>
34
+ </div>
35
+ </div>
36
+ <div class="form-group">
37
+ <div class="actions">
38
+ <%= form.submit "Save preview context", class: "btn btn-primary" %>
39
+ <%= link_to "Cancel", preview_contexts_path, class: "btn btn-light" %>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <div class="card">
2
+ <div class="card-body">
3
+ <div class="row">
4
+ <div class="col-sm">
5
+ <h1>Edit Preview Context</h1>
6
+ </div>
7
+ </div>
8
+ <%= render 'form', preview_context: @preview_context %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,43 @@
1
+ <div class="row">
2
+ <% if notice %>
3
+ <div class="col-sm">
4
+ <span id="notice"><%= notice %></span>
5
+ </div>
6
+ <% end %>
7
+ </div>
8
+
9
+ <div class="row">
10
+ <div class="col-sm-6">
11
+ <h1>Preview Contexts</h1>
12
+ </div>
13
+ <div class="col-sm-6">
14
+ <%= link_to "New preview context", new_preview_context_path, class: "btn btn-primary float-right"%>
15
+ </div>
16
+ </div>
17
+
18
+ <table class="table">
19
+ <thead>
20
+ <tr>
21
+ <th>Title</th>
22
+ <th>Id</th>
23
+ <th>Type</th>
24
+
25
+ <th colspan="3"></th>
26
+ </tr>
27
+ </thead>
28
+
29
+ <tbody>
30
+ <% @preview_contexts.each do |preview_context| %>
31
+ <tr>
32
+ <td><%= link_to preview_context.title, preview_context %></td>
33
+ <td><%= preview_context.id %></td>
34
+
35
+ <td>
36
+ <%= link_to "Delete", preview_context, method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-light" %>
37
+ </td>
38
+ </tr>
39
+ <% end %>
40
+ </tbody>
41
+ </table>
42
+
43
+ <br>
@@ -0,0 +1,10 @@
1
+ <div class="card">
2
+ <div class="card-body">
3
+ <div class="row">
4
+ <div class="col-sm">
5
+ <h1>New Preview Context</h1>
6
+ </div>
7
+ </div>
8
+ <%= render 'form', preview_context: @preview_context %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,45 @@
1
+ <div class="row">
2
+ <div class="col-sm">
3
+ <% if notice %>
4
+ <div class="alert alert-success">
5
+ <span id="notice"><%= notice %></span>
6
+ </div>
7
+ <% end %>
8
+ </div>
9
+ </div>
10
+
11
+ <div class="row" style="margin-bottom: 32px;">
12
+ <div class="col-sm-6">
13
+ <h1><%= @preview_context.title %></h1>
14
+ </div>
15
+ <div class="col-sm-6">
16
+ <%= link_to "Edit", edit_preview_context_path(@preview_context), class: "btn btn-primary float-right" %>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="row">
21
+ <div class="col-sm-3">
22
+ <div class="list-group" id="preview-context-sections-tab" role="tablist">
23
+ <a class="list-group-item list-group-item-action active" id="list-preview-context-input-params" data-toggle="list" href="#preview-context-input-params" role="tab" aria-controls="preview-context-input-params">Input Params</a>
24
+ <a class="list-group-item list-group-item-action" id="list-preview-context-input-headers" data-toggle="list" href="#preview-context-input-headers" role="tab" aria-controls="preview-context-input-headers">Input Headers</a>
25
+ <% @preview_context.data.keys.each do |key| %>
26
+ <a class="list-group-item list-group-item-action" id="list-preview-<%= key %>" data-toggle="list" href="#preview-context-<%= key %>" role="tab" aria-controls="preview-context-<%= key %>"><%= key %></a>
27
+ <% end %>
28
+ </div>
29
+ </div>
30
+ <div class="col-sm-9">
31
+ <div class="tab-content" id="nav-tabContent">
32
+ <div class="tab-pane fade show active" id="preview-context-input-params" role="tabpanel" aria-labelledby="list-preview-context-input-params">
33
+ <pre><%= @preview_context.params %></pre>
34
+ </div>
35
+ <div class="tab-pane fade" id="preview-context-input-headers" role="tabpanel" aria-labelledby="list-preview-context-input-headers">
36
+ <pre><%= @preview_context.headers %></pre>
37
+ </div>
38
+ <% @preview_context.data.each do |key, val| %>
39
+ <div class="tab-pane fade" id="preview-context-<%= key %>" role="tabpanel" aria-labelledby="list-preview-context-<%= key %>">
40
+ <pre><%= val.to_yaml %></pre>
41
+ </div>
42
+ <% end %>
43
+ </div>
44
+ </div>
45
+ </div>
@@ -0,0 +1,19 @@
1
+ <% if publish_request.approved_at.present? %>
2
+ <span class="sm float-right">Approved <%= time_ago_in_words publish_request.approved_at %> ago</span>
3
+ <% elsif riddler_user_can_approve? %>
4
+ <%= link_to "Approve", approve_publish_request_path(publish_request), method: :post, remote: true, class: "btn btn-secondary float-right" %>
5
+ <% else %>
6
+ Not Approved
7
+ <% end %>
8
+
9
+ <% if publish_request.approved_at.present? %>
10
+ <% if publish_request.published_at.present? %>
11
+ <span class="sm float-right">Published <%= time_ago_in_words publish_request.published_at %> ago</span>
12
+ <% else %>
13
+ <%= link_to "Publish", publish_publish_request_path(publish_request), method: :post, remote: true, class: "btn btn-secondary float-right" %>
14
+ <% end %>
15
+ <% end %>
16
+
17
+ <% unless publish_request.published? %>
18
+ <%= link_to "Edit", edit_publish_request_path(publish_request), class: "btn btn-primary float-right" %>
19
+ <% end %>
@@ -0,0 +1,53 @@
1
+ <%= form_with model: publish_request, local: true do |form| %>
2
+ <%= form.hidden_field :content_type %>
3
+ <%= form.hidden_field :content_id %>
4
+
5
+ <% if publish_request.errors.any? %>
6
+ <div class="row">
7
+ <div id="error_explanation">
8
+ <h2><%= pluralize(publish_request.errors.count, "error") %> prohibited this preview context from being saved:</h2>
9
+
10
+ <ul>
11
+ <% publish_request.errors.full_messages.each do |message| %>
12
+ <li><%= message %></li>
13
+ <% end %>
14
+ </ul>
15
+ </div>
16
+ </div>
17
+ <% end %>
18
+
19
+ <div class="row">
20
+ <div class="col">
21
+ <h4><%= publish_request.content.short_name %> <%= publish_request.content.content_type %>: <%= publish_request.content.title %>
22
+ </div>
23
+ </div>
24
+
25
+ <div class="row">
26
+ <div class="col">
27
+ <div class="form-group">
28
+ <div class="field">
29
+ <%= form.label :title %>
30
+ <%= form.text_field :title, class:"form-control" %>
31
+ </div>
32
+ </div>
33
+ <div class="form-group">
34
+ <div class="field">
35
+ <%= form.label :description %>
36
+ <%= form.text_area :description, class:"form-control", rows: 3 %>
37
+ </div>
38
+ </div>
39
+ <div class="form-group">
40
+ <div class="field">
41
+ Definition:
42
+ <textarea class="form-control" rows="6" disabled><%= @definition %></textarea>
43
+ </div>
44
+ </div>
45
+ <div class="form-group">
46
+ <div class="actions">
47
+ <%= form.submit "Save publish request", class: "btn btn-primary" %>
48
+ <%= link_to "Cancel", publish_requests_path, class: "btn btn-light" %>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <% end %>
@@ -0,0 +1,2 @@
1
+ $("#<%= @publish_request.id %>-actions")
2
+ .html("<%= j render partial: "riddler_admin/publish_requests/actions", locals: { publish_request: @publish_request } %>")
@@ -0,0 +1,10 @@
1
+ <div class="card">
2
+ <div class="card-body">
3
+ <div class="row">
4
+ <div class="col-sm">
5
+ <h1>Edit Publish Request</h1>
6
+ </div>
7
+ </div>
8
+ <%= render 'form', publish_request: @publish_request %>
9
+ </div>
10
+ </div>