action_admin 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f5a65a3d49134131805423322fd40c7b66b7520
4
- data.tar.gz: 6bbba84f33f86e1dfa1d4be12e663746b6ef95b2
3
+ metadata.gz: 9c130d9173df9250a76f41a1fb2687c8042ac842
4
+ data.tar.gz: d26a179831e85af820d332744ad27b64c15e2380
5
5
  SHA512:
6
- metadata.gz: fa326acf06c41b654146b5ff48c61d332c2dbda5a42e3273301c2244ca8a48cfec4f557d4459e90aa430bbc8cc922e7813eb2d1332fa361bd3a47357be61b254
7
- data.tar.gz: ad25a999ffbd4129fda022e04b69f47c98ccce3b6153b5d233ce29804fc484da6d9ebb04b063ab6b5fb22d95d2fcde49209f91f41492d39009e0c3d3c9ed4a7a
6
+ metadata.gz: 9c081bec36607b46f36237b4782fcd56f871bcfbd3a7c2bc55d1695df3452260751d25512991006f73b2940214acced809d883389306f2f046626119ffc5f882
7
+ data.tar.gz: e3168380227a10278a910c516a423b840bb5c16a458dd9d637df1046724367e2eeecc996978a1aaf5312604e036845d32908473be8481d6b457387e9827218d1
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:cc="http://creativecommons.org/ns#"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
+ xmlns:svg="http://www.w3.org/2000/svg"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ id="svg2"
9
+ height="250"
10
+ width="250"
11
+ version="1.1">
12
+ <defs
13
+ id="defs4" />
14
+ <metadata
15
+ id="metadata7">
16
+ <rdf:RDF>
17
+ <cc:Work
18
+ rdf:about="">
19
+ <dc:format>image/svg+xml</dc:format>
20
+ <dc:type
21
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
22
+ <dc:title></dc:title>
23
+ </cc:Work>
24
+ </rdf:RDF>
25
+ </metadata>
26
+ <path
27
+ d="M 0,-1.5258789e-5 H 250 V 250 H 0 Z"
28
+ id="rect3126"
29
+ style="fill:#cccccc;fill-opacity:1;stroke:none;stroke-width:0.79056942" />
30
+ <path
31
+ d="m 161.401,117.51166 c -2.14973,-18.309425 -17.6266,-32.511675 -36.40113,-32.511675 -18.77454,0 -34.25114,14.20225 -36.40087,32.511675 -13.03272,0 -23.599,10.63051 -23.599,23.74417 0,13.11364 10.5649,23.74415 23.59762,23.74415 h 72.80477 c 13.03271,0 23.59761,-10.63051 23.59761,-23.74415 0,-13.11366 -10.56627,-23.74417 -23.599,-23.74417 z m -58.41308,32.26113 c -2.27933,0 -4.12723,-1.85937 -4.12723,-4.15286 0,-2.29349 1.8479,-4.15287 4.12723,-4.15287 2.27934,0 4.12724,1.85938 4.12724,4.15287 0,2.29377 -1.84762,4.15286 -4.12724,4.15286 z m 22.01195,0 c -2.27935,0 -4.12725,-1.85937 -4.12725,-4.15286 0,-2.29349 1.8479,-4.15287 4.12725,-4.15287 2.27933,0 4.12723,1.85938 4.12723,4.15287 0,2.29349 -1.84762,4.15286 -4.12723,4.15286 z m 22.01194,0 c -2.27935,0 -4.12725,-1.85937 -4.12725,-4.15286 0,-2.29349 1.8479,-4.15287 4.12725,-4.15287 2.27933,0 4.12723,1.85938 4.12723,4.15287 0,2.29349 -1.84763,4.15286 -4.12723,4.15286 z"
32
+ id="path3149"
33
+ style="fill:#808080;fill-opacity:1" />
34
+ </svg>
@@ -1,12 +1,70 @@
1
1
  @import "foundation-components";
2
2
  @import "bedrock-components";
3
3
 
4
+
5
+ // Panels
6
+
4
7
  .panel {
5
8
 
6
- .input:last-child {
9
+ .input:last-child:not(.error) {
7
10
 
8
11
  input, textarea, select, .select2 {
9
12
  margin-bottom: 0;
10
13
  }
11
14
  }
15
+
16
+ .input.error:last-child {
17
+
18
+ .form-error {
19
+ margin-bottom: 0;
20
+ }
21
+ }
22
+ }
23
+
24
+
25
+ // Invalid Inputs
26
+
27
+ .input.error {
28
+
29
+ input, textarea, select {
30
+ @include form-input-error;
31
+ }
32
+
33
+ &.attachment {
34
+ @include form-input-error;
35
+ border: 1px solid;
36
+ color: $alert-color;
37
+ position: relative;
38
+ padding-bottom: $global-padding * 2;
39
+
40
+ .no-content {
41
+ color: $alert-color;
42
+ }
43
+
44
+ .form-error {
45
+ text-align: center;
46
+ position: absolute;
47
+ bottom: 0;
48
+ left: 0;
49
+ width: 100%;
50
+ background: $alert-color;
51
+ color: $white;
52
+ margin: 0;
53
+ padding: ($global-padding / 4) ($global-padding / 2);
54
+ }
55
+ }
56
+
57
+ }
58
+
59
+ .input-group-list {
60
+
61
+ .input.error {
62
+
63
+ .form-error {
64
+ margin: 0;
65
+ background: $alert-color;
66
+ color: $white;
67
+ padding: ($global-padding / 4) ($global-padding / 2);
68
+ }
69
+ }
12
70
  }
@@ -4,3 +4,19 @@
4
4
  @include foundation-typography;
5
5
  @include foundation-button;
6
6
  @include foundation-forms;
7
+
8
+
9
+ // Custom styles
10
+
11
+ body {
12
+ margin: $global-margin / 2;
13
+ font-size: inherit !important;
14
+ }
15
+
16
+ img[data-mce-style*="float: left"] {
17
+ margin-right: $global-margin;
18
+ }
19
+
20
+ img[data-mce-style*="float: right"] {
21
+ margin-left: $global-margin;
22
+ }
@@ -6,7 +6,10 @@ module ActionAdmin
6
6
  include Controller
7
7
 
8
8
  class_attribute :action_header
9
- self.action_header = Header.new
9
+ class_attribute :_action_templates
10
+
11
+ self.action_header = Header.new
12
+ self._action_templates = {}
10
13
  end
11
14
 
12
15
  class_methods do
@@ -16,6 +19,12 @@ module ActionAdmin
16
19
  self.action_header.action(nil)
17
20
  end
18
21
 
22
+ def action_template(action, template, options={})
23
+ self._action_templates = self._action_templates.merge(
24
+ action => options.merge(partial: "admin/templates/#{template}")
25
+ )
26
+ end
27
+
19
28
  def header(action, &block)
20
29
  self.action_header.action(action)
21
30
  yield self.action_header
@@ -38,5 +38,13 @@ module ActionAdmin
38
38
  def admin_present_many(records, presenter=nil)
39
39
  records.to_a.map { |r| admin_present(r, presenter) }
40
40
  end
41
+
42
+ def admin_render_template(fallback)
43
+ template = Hash(controller._action_templates[:"#{action_name}"])
44
+ partial = template.fetch :partial, fallback
45
+ options = template.except(:partial)
46
+
47
+ render partial, options
48
+ end
41
49
  end
42
50
  end
@@ -34,7 +34,7 @@ module ActionAdmin
34
34
  end
35
35
 
36
36
  def attachment(image_url=nil)
37
- image = content_tag :img, nil, src: image_url, class: 'width-100 margin-bottom-1', data: { src: :id, url: "#{template.root_url.chomp('/')}[src]" }
37
+ image = content_tag :img, nil, src: image_url, class: 'width-100 margin-bottom-1', data: { src: 'file.preview.url', url: "#{template.root_url.chomp('/')}[src]" }
38
38
  button = content_tag :a, 'Remove Thumbnail', class: 'button alert small hollow margin-0', data: { remove: '' }
39
39
 
40
40
  content_tag :div, hidden_input + image + button, class: 'attachment text-center', data: { list_item: '' }
@@ -0,0 +1,62 @@
1
+ module ActionAdmin
2
+ class UploadInput < SimpleForm::Inputs::FileInput
3
+ def input(wrapper_options)
4
+ out = ActiveSupport::SafeBuffer.new
5
+ data = { file_input: '', previews_container: "##{input_html_id}-preview" }
6
+ html = content_tag :div, input_placeholder, id: input_html_id, class: 'dropzone', data: data
7
+
8
+ out << html
9
+ out << input_template
10
+ end
11
+
12
+ def input_placeholder
13
+ span = content_tag :span, 'Drop file here', class: 'margin-bottom-1'
14
+ icon = content_tag :i, nil, class: 'mdi mdi-upload'
15
+ button = content_tag :label, 'Upload File', for: attr_html_id, class: 'button success small hollow margin-0'
16
+ content = content_tag :div, icon + span + file_input + button, class: 'no-content'
17
+ image = attachment(attachment_url) if attachment_url.present?
18
+
19
+ content_tag(:div, content, class: 'dz-message bordered') +
20
+ content_tag(:div, image, id: "#{input_html_id}-preview")
21
+ end
22
+
23
+ def file_input
24
+ @builder.file_field(attribute_name, input_html_options)
25
+ end
26
+
27
+ def hidden_input
28
+ if object.respond_to?("#{attribute_name}_cache")
29
+ @builder.hidden_field("#{attribute_name}_cache")
30
+ else
31
+ ''.html_safe
32
+ end
33
+ end
34
+
35
+ def attr_html_id
36
+ file_input[/id=\"(.*)\"/, 1]
37
+ end
38
+
39
+ def input_html_id
40
+ attr_html_id.dasherize
41
+ end
42
+
43
+ def attachment_url
44
+ object.send(attribute_name).try(:url)
45
+ end
46
+
47
+ def attachment(image_url=nil)
48
+ image = content_tag :img, nil, src: image_url, class: 'width-100 margin-bottom-1', 'dz-thumbnail' => ''
49
+ button = content_tag :a, 'Remove File', class: 'button alert small hollow margin-0', 'dz-remove' => ''
50
+
51
+ content_tag :div, hidden_input + image + button, class: 'text-center'
52
+ end
53
+
54
+ def input_template
55
+ content_tag :script, attachment, id: "#{input_html_id}-preview-template", type: 'text/template'
56
+ end
57
+
58
+ def label(wrapper_options)
59
+ ''
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,11 @@
1
+ script#dropzone-preview-template type="text/template"
2
+ .attachment
3
+ .thumbnail
4
+ img data-dz-thumbnail="" src=asset_url('admin/upload-preview.svg')
5
+ span.filename data-dz-name=""
6
+ span.size data-dz-size=""
7
+ .progress.success
8
+ span.progress-meter data-dz-uploadprogress=""
9
+ i.icon-success.mdi.mdi-check
10
+ i.icon-error.mdi.mdi-close
11
+ .message data-dz-errormessage=""
@@ -0,0 +1,59 @@
1
+ ruby:
2
+ current_record = Medium.new
3
+ options = {
4
+ dropzone_upload: "",
5
+ clickable: "#media-modal-upload-button",
6
+ previews_container: "#media-modal-upload-previews",
7
+ param_name: "medium[file]",
8
+ thumbnail_height: "300",
9
+ thumbnail_width: "300"
10
+ }
11
+
12
+ #media-modal.reveal.full.reveal-panel data-media-reveal="" data-media-url=admin_media_url(per_page: 10000, format: :json)
13
+ .panel
14
+ .panel-header.border
15
+ = 'Add Media'
16
+ button.close-button aria-label='Close modal' data-close="" type="button"
17
+ span aria-hidden="true" &times;
18
+
19
+ .panel-header.border.padding-0
20
+ ul#media-modal-tabs.tabs.padding-0.border-none data-tabs=""
21
+ li.tabs-title.is-active
22
+ a aria-selected="true" href="#media-modal-library"
23
+ i.mdi.mdi-play-circle-outline
24
+ | Library
25
+ li.tabs-title
26
+ a href="#media-modal-uploads"
27
+ i.mdi.mdi-upload
28
+ | Upload
29
+
30
+ .panel-content.border.padding-0
31
+ .tabs-content.border-none.padding-0 data-tabs-content="media-modal-tabs"
32
+ #media-modal-library.tabs-panel.is-active
33
+ .attachments-grid data-list-select=""
34
+ #media-modal-uploads.tabs-panel
35
+ = admin_form_for([:admin, current_record], html: { id: 'media-modal-upload', class: 'dropzone', data: options }) do |f|
36
+ = f.input :file, as: :hidden
37
+
38
+ .dz-message.bordered.margin-bottom-1
39
+ .no-content
40
+ i.mdi.mdi-upload
41
+ span = 'Drop files here to upload'
42
+ a#media-modal-upload-button.button.success.hollow.margin-top-1 = 'Select Files'
43
+
44
+ #media-modal-upload-previews.attachments-grid
45
+
46
+ .panel-footer
47
+ .grid-x
48
+ .cell.auto
49
+ button.button.hollow.alert.margin-0 aria-label='Close modal' data-close="" type="button" = 'Close'
50
+
51
+ .cell.shrink
52
+ button.button.margin-0 aria-label='Insert Media' data-insert="" type="button" = 'Insert Media'
53
+
54
+ script#media-modal-item-template type="text/template"
55
+ .attachment data-list-item=""
56
+ .thumbnail
57
+ img data-src="file.small.url" data-url="#{root_url.chomp('/')}[src]" src=asset_url('admin/upload-preview.svg')
58
+ span.filename data-text="name"
59
+ span.check-button.mdi.mdi-check
@@ -1 +1 @@
1
- = render 'form'
1
+ = admin_render_template 'form'
@@ -1 +1 @@
1
- = render 'form'
1
+ = admin_render_template 'form'
@@ -0,0 +1,22 @@
1
+ ruby:
2
+ options = {
3
+ dropzone_upload: "",
4
+ clickable: "#media-upload-button",
5
+ previews_container: "#media-upload-previews",
6
+ param_name: "#{current_record.class.model_name.singular}[#{field}]",
7
+ thumbnail_height: "300",
8
+ thumbnail_width: "300"
9
+ }
10
+
11
+ = admin_form_for([:admin, current_record], html: { id: 'media-upload', class: 'dropzone', data: options }) do |f|
12
+ = f.input field, as: :hidden
13
+
14
+ .panel
15
+ .panel-content
16
+ .dz-message.bordered
17
+ .no-content
18
+ i.mdi.mdi-upload
19
+ span = 'Drop files here to upload'
20
+ a#media-upload-button.button.success.hollow.margin-top-1 = 'Select Files'
21
+
22
+ #media-upload-previews.attachments-grid
@@ -20,6 +20,8 @@ html
20
20
  = render 'admin/common/header'
21
21
  = yield
22
22
  = render 'admin/common/footer'
23
+ = render 'admin/common/media_modal'
24
+ = render 'admin/common/dropzone_template'
23
25
 
24
26
  #offcanvas.off-canvas.position-right data-off-canvas=""
25
27
  = render 'admin/common/messagebar'
@@ -11,7 +11,8 @@ module ActionAdmin
11
11
  app.config.assets.paths << root.join('app', 'assets', 'images', sf).to_s
12
12
  end
13
13
 
14
- app.config.assets.precompile += %w(admin/application.js admin/application.css admin/tinymce-editor.css images/admin/*.*)
14
+ app.config.assets.precompile += %w(admin/application.js admin/application.css admin/tinymce-editor.css)
15
+ app.config.assets.precompile += %w(images/admin/*.* admin/*.svg admin/*.png)
15
16
  end
16
17
 
17
18
  initializer 'action_admin', before: :load_config_initializers do
@@ -51,8 +51,8 @@ module ActionAdmin
51
51
  return {} unless context.controller.respond_to? :permitted_params
52
52
 
53
53
  {
54
- show: { label: 'View', icon: 'eye', url: :record_path },
55
- index: { label: 'Back', icon: 'arrow-left', url: :records_path, html: { class: 'inactive' } },
54
+ show: { label: 'View', icon: 'eye', url: :record_path, html: { class: 'success' } },
55
+ index: { label: 'Back', icon: 'arrow-left', url: :records_path, html: { class: 'secondary' } },
56
56
  new: { label: 'New', icon: 'plus', url: :new_record_path, html: { class: 'success' } },
57
57
  edit: { label: 'Edit', icon: 'pencil', url: :edit_record_path, html: { class: 'warning' } },
58
58
  destroy: { label: 'Delete', icon: 'delete', url: :record_path, html: { class: 'alert' }, method: 'delete' }
@@ -1,3 +1,3 @@
1
1
  module ActionAdmin
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonian Guveli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2017-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -175,6 +175,7 @@ files:
175
175
  - README.md
176
176
  - Rakefile
177
177
  - app/assets/images/admin/logo.svg
178
+ - app/assets/images/admin/upload-preview.svg
178
179
  - app/assets/javascripts/action_admin/action-admin.js
179
180
  - app/assets/javascripts/admin/application.js
180
181
  - app/assets/stylesheets/action_admin/action-admin.scss
@@ -202,6 +203,7 @@ files:
202
203
  - app/inputs/action_admin/tag_list_input.rb
203
204
  - app/inputs/action_admin/tinymce_input.rb
204
205
  - app/inputs/action_admin/title_input.rb
206
+ - app/inputs/action_admin/upload_input.rb
205
207
  - app/presenters/action_admin/presenter.rb
206
208
  - app/presenters/concerns/action_admin/presentable.rb
207
209
  - app/views/action_admin/devise/confirmations/new.html.slim
@@ -214,9 +216,11 @@ files:
214
216
  - app/views/action_admin/devise/unlocks/new.html.slim
215
217
  - app/views/action_admin/welcome/index.html.slim
216
218
  - app/views/admin/common/_alerts.html.slim
219
+ - app/views/admin/common/_dropzone_template.html.slim
217
220
  - app/views/admin/common/_footer.html.slim
218
221
  - app/views/admin/common/_header.html.slim
219
222
  - app/views/admin/common/_logobar.html.slim
223
+ - app/views/admin/common/_media_modal.html.slim
220
224
  - app/views/admin/common/_messagebar.html.slim
221
225
  - app/views/admin/common/_noresults.html.slim
222
226
  - app/views/admin/common/_sidebar.html.slim
@@ -231,6 +235,7 @@ files:
231
235
  - app/views/admin/records/index.html.slim
232
236
  - app/views/admin/records/new.html.slim
233
237
  - app/views/admin/records/show.html.slim
238
+ - app/views/admin/templates/_upload.html.slim
234
239
  - app/views/layouts/admin.html.slim
235
240
  - app/views/layouts/admin/devise.html.slim
236
241
  - config/initializers/admin_simple_form.rb