zadok 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/zadok_helper.rb +24 -0
- data/app/views/zadok/edit.html.slim +19 -0
- data/app/views/zadok/form/fields/_email_field.html.slim +3 -0
- data/app/views/zadok/form/fields/_select.html.slim +4 -0
- data/app/views/zadok/form/fields/_text_field.html.slim +3 -0
- data/app/views/zadok/index.html.slim +27 -0
- data/app/views/zadok/new.html.slim +13 -0
- data/lib/zadok/version.rb +1 -1
- data/lib/zadok_link_renderer.rb +23 -0
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60700305f68cd9f4c86d861db2ed702ea3e838a1e19822e944af02ef88bde6ab
|
4
|
+
data.tar.gz: bb8e5f391442652b5912c2bdb265a3b2fb5d0b1397043eaa6b1359a518ccd7a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,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
@@ -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, "…"))
|
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.
|
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:
|