lotus_admin 1.1.1 → 1.2.0
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 +4 -4
- data/app/controllers/lotus_admin/resource_controller.rb +51 -0
- data/app/views/lotus_admin/resource/_form.html.haml +12 -0
- data/app/views/lotus_admin/resource/edit.html.haml +12 -0
- data/app/views/lotus_admin/resource/index.html.haml +19 -0
- data/app/views/lotus_admin/resource/new.html.haml +9 -0
- data/app/views/lotus_admin/resource/show.html.haml +18 -0
- data/lib/lotus_admin/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7208f071236d1a2e2c9eb5450358f00ad454577c2e117da684e71803ec3eaf94
|
4
|
+
data.tar.gz: b8e570f7a12ca833c6c96fc4730c2794098638563d97a1cc667ca6764fd25baf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec7d32411bc5bcecb60dd421f24f8b47e4ccc2d44594ea17fc58d14552d281bb2b6a22f53adbfc2cf9006b8eb326dcddc141bf2e87c386fd7df79d0a896f918f
|
7
|
+
data.tar.gz: 1b1bdca8ed78b5765c93356781394044f9163a3f0e2fcf6cf279137c5f31d445867e7e00dff89ab03714ea72a0a54276952d4c368a78093518fa23d7ad69fa01
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
|
2
|
+
let(:resource) { resource_class.find(params[:id]) }
|
3
|
+
|
4
|
+
before_action :set_view_paths, only: [:new, :edit, :index, :show]
|
5
|
+
|
6
|
+
def new
|
7
|
+
self.resource = build_resource
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
self.resource = build_resource(permitted_params)
|
12
|
+
|
13
|
+
if resource.save
|
14
|
+
redirect_to [lotus_admin, resource], notice: "Created new #{ resource_class.model_name.human } successfully"
|
15
|
+
else
|
16
|
+
render :new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
if resource.update(permitted_params)
|
22
|
+
redirect_to [lotus_admin, resource], notice: "Updated new #{ resource_class.model_name.human } successfully"
|
23
|
+
else
|
24
|
+
render :edit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def destroy
|
29
|
+
if resource.destroy
|
30
|
+
flash[:notice] = "#{ resource_class.model_name.human } has been removed"
|
31
|
+
else
|
32
|
+
flash[:error] = "There was an error removing that #{ resource_class.model_name.human }"
|
33
|
+
end
|
34
|
+
|
35
|
+
redirect_to [lotus_admin, resource_class]
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def build_resource(*params)
|
41
|
+
current_organization.association(association_name).build(params)
|
42
|
+
end
|
43
|
+
|
44
|
+
def association_name
|
45
|
+
resource_class.model_name.plural
|
46
|
+
end
|
47
|
+
|
48
|
+
def set_view_paths
|
49
|
+
append_view_path("lotus_admin/resource/#{ action_name }")
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
= material_form_for [lotus_admin, resource] do |f|
|
2
|
+
.form-inputs
|
3
|
+
- f.object.class.columns.each do |column|
|
4
|
+
- case column.type
|
5
|
+
- when :text
|
6
|
+
= f.input column.name, as: :text, input_html: { rows: 5 }
|
7
|
+
- else
|
8
|
+
= f.input column.name
|
9
|
+
|
10
|
+
.form-actions
|
11
|
+
= material_form_submit(resource)
|
12
|
+
= material_form_cancel(lotus_admin.polymorphic_path(resource_class))
|
@@ -0,0 +1,19 @@
|
|
1
|
+
- content_for :action_items do
|
2
|
+
%li= new_link
|
3
|
+
|
4
|
+
= render_index do
|
5
|
+
.table-responsive
|
6
|
+
%table.table.table-striped.table-bordered
|
7
|
+
%thead
|
8
|
+
%th= resource_class.human_attribute_name(:id)
|
9
|
+
%th
|
10
|
+
|
11
|
+
%tbody
|
12
|
+
- collection.each do |resource|
|
13
|
+
%tr
|
14
|
+
%td= link_to resource.id, [lotus_admin, resource]
|
15
|
+
%td.actions-col
|
16
|
+
%ul.actions
|
17
|
+
%li= view_link(resource)
|
18
|
+
%li= edit_link(resource)
|
19
|
+
%li= destroy_link(resource)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
.block-header
|
2
|
+
%h2= page_title!("#{ resource_class.model_name.human } Details")
|
3
|
+
|
4
|
+
%ul.actions
|
5
|
+
%li= edit_link(resource)
|
6
|
+
%li= destroy_link(resource)
|
7
|
+
%li= new_link
|
8
|
+
|
9
|
+
.card
|
10
|
+
.card-header
|
11
|
+
%h2= resource_class.model_name.human
|
12
|
+
|
13
|
+
.card-body
|
14
|
+
.row
|
15
|
+
.col-sm-12
|
16
|
+
.list-group
|
17
|
+
- resource.attributes.keys.each do |attribute|
|
18
|
+
= panel_attribute(resource, attribute)
|
data/lib/lotus_admin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lotus_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Millsaps-Brewer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -360,6 +360,7 @@ files:
|
|
360
360
|
- app/controllers/lotus_admin/dashboard_controller.rb
|
361
361
|
- app/controllers/lotus_admin/passwords_controller.rb
|
362
362
|
- app/controllers/lotus_admin/profiles_controller.rb
|
363
|
+
- app/controllers/lotus_admin/resource_controller.rb
|
363
364
|
- app/controllers/lotus_admin/sessions_controller.rb
|
364
365
|
- app/controllers/lotus_admin/users_controller.rb
|
365
366
|
- app/helpers/lotus_admin/application_helper.rb
|
@@ -408,6 +409,11 @@ files:
|
|
408
409
|
- app/views/layouts/lotus_admin/mailer.text.erb
|
409
410
|
- app/views/lotus_admin/dashboard/show.html.haml
|
410
411
|
- app/views/lotus_admin/profiles/edit.html.haml
|
412
|
+
- app/views/lotus_admin/resource/_form.html.haml
|
413
|
+
- app/views/lotus_admin/resource/edit.html.haml
|
414
|
+
- app/views/lotus_admin/resource/index.html.haml
|
415
|
+
- app/views/lotus_admin/resource/new.html.haml
|
416
|
+
- app/views/lotus_admin/resource/show.html.haml
|
411
417
|
- app/views/lotus_admin/shared/_collection_pagination.html.haml
|
412
418
|
- app/views/lotus_admin/shared/_index.html.haml
|
413
419
|
- app/views/lotus_admin/shared/filters/_modal.html.haml
|