zadok 0.1.0 → 0.1.1

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: 681f00af0d3fc67f4f4bdbf2d8b48cf7a64f10de783a3f6c5d0693b3e74d3ac7
4
- data.tar.gz: 7025bb3fd0e2f8e8f679a0a6adfe2c9e85d68c3f652d3c1bfbb3c85af7aab1db
3
+ metadata.gz: 60700305f68cd9f4c86d861db2ed702ea3e838a1e19822e944af02ef88bde6ab
4
+ data.tar.gz: bb8e5f391442652b5912c2bdb265a3b2fb5d0b1397043eaa6b1359a518ccd7a0
5
5
  SHA512:
6
- metadata.gz: db58e21d79f67ee8306b04d3b0d2379ea7f214d40073e47b15f5651dd549885cc21140b2bc20654243db034a5921ff790239c3937869224d14aa5fcabb590ef7
7
- data.tar.gz: 69abdc23689ffa6172ff99013f31da1381a0e87a4ead5ebe0bb8d1625c4353c8cd98c10f6d04fefc23ebc0724b79c515d9ea2a6cf9c619f13046a033baf90470
6
+ metadata.gz: ae704128dfb2f14e022c64831109bea22bc729afa1e6156dea715faffb43fc3c3ec223ab8f0c4f96a56578eafcc5fb9501a939412558826692b33d4e9436e495
7
+ data.tar.gz: 37b0aab424ae15b2f3b0a41e9f0c2629780576ba341268fef5240ac499be935c11375690a57aaf0d9b7174b731645dec9503ade7535ff53013b3ef61c53474af
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ZadokHelper
4
+ def resource_url_for(action)
5
+ url_for(controller: resource_name.pluralize, action: action)
6
+ end
7
+
8
+ def sort_table_header(attr, model)
9
+ name = t("activerecord.attributes.#{model}.#{attr}")
10
+
11
+ cell_contents = if current_sort == "#{attr} asc"
12
+ [name, fa_icon("chevron-down", class: "pull-right")]
13
+ elsif current_sort == "#{attr} desc"
14
+ [name, fa_icon("chevron-up", class: "pull-right")]
15
+ else
16
+ [name]
17
+ end
18
+
19
+ content_tag(:th, class: "sortable",
20
+ data: { href: sort_url(current_search, attr) }) do
21
+ safe_join(cell_contents, " ")
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ .container[id="#{resource_name.pluralize}-edit"]
2
+ .card
3
+ .card-body
4
+ h2.card-title
5
+ = t("#{resource_name.pluralize}.edit")
6
+ = link_to t("#{resource_name.pluralize}.index"), resource_url_for(:index), class: "btn btn-primary text-white float-right"
7
+
8
+ = form_for(resource, url: resource_url_for(:update), as: resource_name, html: { class: "bg-white" }) do |form|
9
+ - edit_attributes.each do |attr, options|
10
+ = render "crud/form/fields/#{options[:type]}", resource: resource, form: form, attr: attr, options: options
11
+
12
+ .form-group
13
+ = form.submit class: "btn btn-primary text-white"
14
+ - if can?(:destroy, resource)
15
+ .card-footer
16
+ = link_to(t("#{resource_name.pluralize}.destroy"), resource_url_for(:destroy),
17
+ data: {confirm: t("#{resource_name.pluralize}.destroy_confirm")},
18
+ method: :delete,
19
+ class: "btn btn-danger pull-right")
@@ -0,0 +1,3 @@
1
+ .form-group
2
+ = form.label attr
3
+ = form.email_field attr, options.fetch(:html) { {} }.merge(class: "form-control")
@@ -0,0 +1,4 @@
1
+ .form-group
2
+ = form.label attr
3
+ br
4
+ = form.select attr, options_for_select(options[:options], resource.send(attr)), {}, options.fetch(:html) { {} }.merge(class: "custom-select")
@@ -0,0 +1,3 @@
1
+ .form-group
2
+ = form.label attr
3
+ = form.text_field attr, options.fetch(:html) { {} }.merge(class: "form-control")
@@ -0,0 +1,27 @@
1
+ .container[id="#{resource_name.pluralize}-index"]
2
+ .card
3
+ .card-body
4
+ h2.card-title
5
+ = t("#{resource_name.pluralize}.index")
6
+ - if can?(:create, resource_name.classify.constantize)
7
+ = link_to t("#{resource_name.pluralize}.new"), resource_url_for(:new), class: "btn btn-primary text-white float-right"
8
+
9
+ = render "filters/edit"
10
+
11
+ table.table.table-light.table-bordered.table-striped.table-hover.table-sm
12
+ thead
13
+ tr
14
+ - index_attributes.each do |attr|
15
+ = sort_table_header(attr, resource_name)
16
+ tfoot
17
+ tr
18
+ td.text-right[colspan=index_attributes.count]
19
+ = page_entries_info resources
20
+ tbody
21
+ = render partial: "#{resource_name.pluralize}/index_row", collection: resources, as: :resource
22
+
23
+ = will_paginate resources,
24
+ inner_window: 1,
25
+ outer_window: 0,
26
+ renderer: ZadokLinkRenderer,
27
+ class: "pagination justify-content-center"
@@ -0,0 +1,13 @@
1
+ .container[id="#{resource_name.pluralize}-new"]
2
+ .card
3
+ .card-body
4
+ h2.card-title
5
+ = t("#{resource_name.pluralize}.new")
6
+ = link_to t("#{resource_name.pluralize}.index"), resource_url_for(:index), class: "btn btn-primary text-white float-right"
7
+
8
+ = form_for(resource, html: { class: "bg-white" }) do |form|
9
+ - new_attributes.each do |attr, options|
10
+ = render "crud/form/fields/#{options[:type]}", resource: resource, form: form, attr: attr, options: options
11
+
12
+ .form-group
13
+ = form.submit class: "btn btn-primary text-white"
data/lib/zadok/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zadok
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ZadokLinkRenderer < WillPaginate::ActionView::LinkRenderer
4
+ protected
5
+
6
+ def html_container(html)
7
+ tag(:nav, tag(:ul, html, container_attributes))
8
+ end
9
+
10
+ def page_number(page)
11
+ css_class = page == current_page ? "page-item active" : "page-item"
12
+ tag(:li, link(page, page, rel: rel_value(page), class: "page-link"), class: css_class)
13
+ end
14
+
15
+ def previous_or_next_page(page, text, css_class)
16
+ css_class += " disabled" unless page
17
+ tag(:li, link(text, page || "#", class: "page-link"), class: "page-item #{css_class}")
18
+ end
19
+
20
+ def gap
21
+ tag(:li, tag(:span, "&hellip;"))
22
+ end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zadok
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leon Hooijer
@@ -190,9 +190,17 @@ files:
190
190
  - Gemfile
191
191
  - Gemfile.lock
192
192
  - app/controllers/zadok_controller.rb
193
+ - app/helpers/zadok_helper.rb
194
+ - app/views/zadok/edit.html.slim
195
+ - app/views/zadok/form/fields/_email_field.html.slim
196
+ - app/views/zadok/form/fields/_select.html.slim
197
+ - app/views/zadok/form/fields/_text_field.html.slim
198
+ - app/views/zadok/index.html.slim
199
+ - app/views/zadok/new.html.slim
193
200
  - lib/zadok.rb
194
201
  - lib/zadok/engine.rb
195
202
  - lib/zadok/version.rb
203
+ - lib/zadok_link_renderer.rb
196
204
  - zadok.gemspec
197
205
  homepage: https://github.com/leonhooijer/zadok
198
206
  licenses: