upmin-admin 0.0.39 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -14
- data/Rakefile +24 -15
- data/app/assets/javascripts/upmin/application.js +0 -1
- data/app/assets/stylesheets/upmin/base.css.scss +4 -0
- data/app/assets/stylesheets/upmin/instances.css.scss +11 -1
- data/app/controllers/upmin/models_controller.rb +52 -42
- data/app/views/layouts/upmin/_navbar.html.haml +3 -3
- data/app/views/layouts/upmin/application.html.haml +2 -1
- data/app/views/upmin/models/new.html.haml +3 -3
- data/app/views/upmin/models/search.html.haml +5 -4
- data/app/views/upmin/models/show.html.haml +3 -3
- data/app/views/upmin/partials/actions/_action.html.haml +6 -21
- data/app/views/upmin/partials/associations/_associations.html.haml +8 -10
- data/app/views/upmin/partials/attributes/_boolean.html.haml +8 -6
- data/app/views/upmin/partials/attributes/_datetime.html.haml +38 -36
- data/app/views/upmin/partials/attributes/_decimal.html.haml +10 -0
- data/app/views/upmin/partials/attributes/_float.html.haml +10 -6
- data/app/views/upmin/partials/attributes/_integer.html.haml +10 -6
- data/app/views/upmin/partials/attributes/_progress_bar.html.haml +1 -0
- data/app/views/upmin/partials/attributes/_string.html.haml +17 -6
- data/app/views/upmin/partials/attributes/_text.html.haml +8 -6
- data/app/views/upmin/partials/attributes/_unknown.html.haml +5 -3
- data/app/views/upmin/partials/models/_model.html.haml +18 -46
- data/app/views/upmin/partials/models/_new_model.html.haml +9 -31
- data/app/views/upmin/partials/parameters/_block_parameter.haml +0 -0
- data/app/views/upmin/partials/parameters/_opt_parameter.html.haml +14 -0
- data/app/views/upmin/partials/parameters/_req_parameter.html.haml +4 -0
- data/app/views/upmin/partials/search_boxes/_ransack_search_box.html.haml +2 -3
- data/app/views/upmin/partials/search_results/_results.html.haml +9 -2
- data/lib/upmin/action.rb +50 -0
- data/lib/upmin/active_record/association.rb +47 -0
- data/lib/upmin/active_record/model.rb +54 -0
- data/lib/upmin/active_record/query.rb +12 -0
- data/lib/upmin/admin.rb +24 -2
- data/lib/upmin/association.rb +73 -0
- data/lib/upmin/attribute.rb +87 -0
- data/lib/upmin/automatic_delegation.rb +76 -0
- data/lib/upmin/configuration.rb +103 -0
- data/lib/upmin/data_mapper/association.rb +57 -0
- data/lib/upmin/data_mapper/model.rb +62 -0
- data/lib/upmin/data_mapper/query.rb +57 -0
- data/lib/upmin/engine.rb +2 -0
- data/lib/upmin/errors.rb +43 -0
- data/lib/upmin/model.rb +267 -98
- data/lib/upmin/parameter.rb +43 -0
- data/lib/upmin/query.rb +51 -0
- data/lib/upmin/railtie.rb +11 -1
- data/lib/upmin/railties/active_record.rb +5 -50
- data/lib/upmin/railties/data_mapper.rb +18 -0
- data/lib/upmin/railties/render.rb +34 -98
- data/lib/upmin/railties/render_helpers.rb +119 -53
- data/lib/upmin/version.rb +1 -1
- data/spec/factories/factories.rb +6 -0
- data/spec/features/action_spec.rb +39 -46
- data/spec/features/edit_model_spec.rb +4 -2
- data/spec/features/navbar_spec.rb +48 -0
- data/spec/features/new_model_spec.rb +1 -0
- data/spec/features/search_spec.rb +7 -4
- data/spec/lib/configuration_spec.rb +60 -0
- data/spec/spec_helper.rb +14 -8
- metadata +25 -7
- data/app/assets/javascripts/upmin/moment.js +0 -2856
- data/app/helpers/upmin/instances_helper.rb +0 -13
- data/app/views/upmin/partials/attributes/_nilable.html.haml +0 -14
- data/app/views/upmin/partials/search_results/_result.html.haml +0 -8
- data/lib/upmin/klass.rb +0 -170
@@ -9,13 +9,13 @@
|
|
9
9
|
%button.close{"data-dismiss" => "alert", type: "button"}
|
10
10
|
%span{"aria-hidden" => "true"} ×
|
11
11
|
= alert
|
12
|
-
- if @model.
|
12
|
+
- if @model.errors.any?
|
13
13
|
%ul
|
14
|
-
- @model.
|
14
|
+
- @model.errors.each do |field, error|
|
15
15
|
%li
|
16
16
|
%b
|
17
17
|
= field
|
18
18
|
= error
|
19
19
|
.row
|
20
20
|
.col-sm-12
|
21
|
-
=
|
21
|
+
= up_render(@model)
|
@@ -1,24 +1,9 @@
|
|
1
|
+
%h4{style: "color: #333;"}
|
2
|
+
= action.title
|
1
3
|
.well.action-well
|
2
|
-
= form_tag(
|
3
|
-
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
.form-group
|
8
|
-
= label(action_name, param_name, param_name.to_s.capitalize.gsub("_", " "))
|
9
|
-
|
10
|
-
- if param_type == :opt
|
11
|
-
.input-group
|
12
|
-
= text_field(action_name, param_name, class: "form-control")
|
13
|
-
.input-group-addon.nilable-addon
|
14
|
-
.form-group
|
15
|
-
%label{for: "#{action_name}_#{param_name}_is_nil"}
|
16
|
-
Do Not Provide
|
17
|
-
= check_box(action_name, "#{param_name}_is_nil", class: "boolean")
|
18
|
-
%small
|
19
|
-
* Optional
|
20
|
-
- else
|
21
|
-
= text_field(action_name, param_name, class: "form-control")
|
22
|
-
|
4
|
+
= form_tag(action.path, class: action.name) do
|
5
|
+
- action.parameters.each do |parameter|
|
6
|
+
-# = Upmin::Railties::RenderHelpers.parameter_partials(parameter)
|
7
|
+
= up_render(parameter)
|
23
8
|
|
24
9
|
= submit_tag("Submit", class: "btn btn-primary")
|
@@ -1,14 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
- associations.each do |u|
|
4
|
-
- nested_upmin_model = Upmin::Model.new(u)
|
5
|
-
%a.active-tag-link{href: upmin_model_path(nested_upmin_model.path_hash)}
|
6
|
-
%span.label{class: nested_upmin_model.color}
|
7
|
-
= nested_upmin_model.title
|
1
|
+
%h5
|
2
|
+
= association.title
|
8
3
|
|
9
|
-
-
|
4
|
+
- if association.empty?
|
10
5
|
%p.well
|
11
6
|
None
|
12
7
|
|
13
|
-
|
14
|
-
|
8
|
+
- else
|
9
|
+
- association.upmin_values.each do |m|
|
10
|
+
%a.active-tag-link{href: m.path}
|
11
|
+
%span.label{class: m.color}
|
12
|
+
= m.title
|
@@ -1,8 +1,10 @@
|
|
1
|
-
-
|
1
|
+
.form-group{class: attribute.errors? ? "has-error" : ""}
|
2
|
+
%label{for: attribute.form_id}
|
3
|
+
= attribute.label_name
|
2
4
|
|
3
|
-
- if editable && f = form_builder
|
4
|
-
|
5
|
+
- if attribute.editable? && f = form_builder
|
6
|
+
= f.check_box(attribute.name, value: boolean, class: "boolean")
|
5
7
|
|
6
|
-
- else
|
7
|
-
|
8
|
-
|
8
|
+
- else
|
9
|
+
%p.well
|
10
|
+
= attribute.value
|
@@ -1,36 +1,38 @@
|
|
1
|
-
-
|
2
|
-
|
3
|
-
-
|
4
|
-
|
5
|
-
=
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
%
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
%
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
- iso8601 = attribute.value.nil? ? nil : attribute.value.utc.iso8601
|
2
|
+
|
3
|
+
.form-group{class: attribute.errors? ? "has-error" : ""}
|
4
|
+
%label{for: attribute.form_id}
|
5
|
+
= attribute.label_name
|
6
|
+
|
7
|
+
- if attribute.editable? && f = form_builder
|
8
|
+
.row.datetime-attribute{class: attribute.form_id}
|
9
|
+
= f.hidden_field(attribute.name, value: iso8601)
|
10
|
+
|
11
|
+
.col-xs-12.col-md-4
|
12
|
+
.input-group.pikadate
|
13
|
+
%input.form-control{type: :text, value: iso8601, id: "#{attribute.form_id}-date"}
|
14
|
+
%span.input-group-addon
|
15
|
+
%span.glyphicon.glyphicon-calendar
|
16
|
+
|
17
|
+
.col-xs-12.col-md-4
|
18
|
+
.input-group.clockpicker{"data-align" => "top", "data-autoclose" => "true", "data-placement" => "right"}
|
19
|
+
%input.form-control{type: "text", value: iso8601, id: "#{attribute.form_id}-time"}
|
20
|
+
%span.input-group-addon
|
21
|
+
%span.glyphicon.glyphicon-time
|
22
|
+
|
23
|
+
.col-xs-12.col-md-4
|
24
|
+
%small
|
25
|
+
Date & Time are shown in UTC. If no time is provided, the current time in UTC will be used.
|
26
|
+
|
27
|
+
|
28
|
+
- content_for(:javascript) do
|
29
|
+
:javascript
|
30
|
+
$(document).ready(function() {
|
31
|
+
window.Upmin.Attributes.DateTime("#{attribute.form_id}");
|
32
|
+
});
|
33
|
+
|
34
|
+
|
35
|
+
- else
|
36
|
+
%p.well
|
37
|
+
-# TODO(jon): Make this show an uneditable date and time field.
|
38
|
+
= iso8601
|
@@ -0,0 +1,10 @@
|
|
1
|
+
.form-group{class: attribute.errors? ? "has-error" : ""}
|
2
|
+
%label{for: attribute.form_id}
|
3
|
+
= attribute.label_name
|
4
|
+
|
5
|
+
- if attribute.editable? && f = form_builder
|
6
|
+
= f.text_field(attribute.name, value: attribute.value, class: "form-control")
|
7
|
+
|
8
|
+
- else
|
9
|
+
%p.well
|
10
|
+
= attribute.value
|
@@ -1,7 +1,11 @@
|
|
1
|
-
- float ||= nil
|
2
|
-
- if editable && f = form_builder
|
3
|
-
= f.text_field(attr_name, value: float, class: "form-control")
|
4
1
|
|
5
|
-
-
|
6
|
-
%
|
7
|
-
=
|
2
|
+
.form-group{class: attribute.errors? ? "has-error" : ""}
|
3
|
+
%label{for: attribute.form_id}
|
4
|
+
= attribute.label_name
|
5
|
+
|
6
|
+
- if attribute.editable? && f = form_builder
|
7
|
+
= f.text_field(attribute.name, value: attribute.value, class: "form-control")
|
8
|
+
|
9
|
+
- else
|
10
|
+
%p.well
|
11
|
+
= attribute.value
|
@@ -1,7 +1,11 @@
|
|
1
|
-
- integer ||= nil
|
2
|
-
- if editable && f = form_builder
|
3
|
-
= f.number_field(attr_name, value: integer, class: "form-control")
|
4
1
|
|
5
|
-
-
|
6
|
-
%
|
7
|
-
=
|
2
|
+
.form-group{class: attribute.errors? ? "has-error" : ""}
|
3
|
+
%label{for: attribute.form_id}
|
4
|
+
= attribute.label_name
|
5
|
+
|
6
|
+
- if attribute.editable? && f = form_builder
|
7
|
+
= f.number_field(attribute.name, value: attribute.value, class: "form-control")
|
8
|
+
|
9
|
+
- else
|
10
|
+
%p.well
|
11
|
+
= attribute.value
|
@@ -1,7 +1,18 @@
|
|
1
|
-
-
|
2
|
-
- if editable && f = form_builder
|
3
|
-
= f.text_field(attr_name, value: string, class: "form-control")
|
1
|
+
- is_nil = model.new_record? ? false : attribute.value.nil?
|
4
2
|
|
5
|
-
-
|
6
|
-
%
|
7
|
-
=
|
3
|
+
.form-group{class: attribute.errors? ? "has-error" : ""}
|
4
|
+
%label{for: attribute.form_id}
|
5
|
+
= attribute.label_name
|
6
|
+
|
7
|
+
- if attribute.editable? && f = form_builder
|
8
|
+
.input-group
|
9
|
+
= f.text_field(attribute.name, value: attribute.value, class: "form-control")
|
10
|
+
.input-group-addon.nilable-addon
|
11
|
+
.form-group
|
12
|
+
%label{for: "#{attribute.form_id}_is_nil"}
|
13
|
+
Make this Nil
|
14
|
+
= check_box(model.underscore_name, "#{attribute.name}_is_nil", class: "boolean", checked: is_nil, value: is_nil)
|
15
|
+
|
16
|
+
- else
|
17
|
+
%p.well
|
18
|
+
= attribute.value
|
@@ -1,7 +1,9 @@
|
|
1
|
-
-
|
2
|
-
|
3
|
-
|
1
|
+
.form-group{class: attribute.errors? ? "has-error" : ""}
|
2
|
+
%label{for: attribute.form_id}
|
3
|
+
= attribute.label_name
|
4
|
+
- if attribute.editable? && f = form_builder
|
5
|
+
= f.text_area(attribute.name, value: attribute.value, rows: 4, class: "form-control")
|
4
6
|
|
5
|
-
- else
|
6
|
-
|
7
|
-
|
7
|
+
- else
|
8
|
+
%p.well
|
9
|
+
= attribute.value
|
@@ -1,72 +1,44 @@
|
|
1
|
-
|
2
|
-
-# unknown - This is the model passed into the up_model method.
|
3
|
-
-# This attribute is always present in any partial rendered
|
4
|
-
-# by Upmin, and will always match the name of the partial
|
5
|
-
-# *UNLESS* nil, true, or false are passed in.
|
6
|
-
-# upmin_model - This is an Upmin::Model instantiated with unknown
|
7
|
-
-# and is always present.
|
8
|
-
-#
|
9
|
-
-# In general, the upmin_model makes it significantly easier to
|
10
|
-
-# render a view, so I suggest using it. It is way simpler than
|
11
|
-
-# trying to find all associations for a model on your own.
|
12
|
-
-#
|
13
|
-
-# Just an FYI: upmin_model.instance == unknown
|
14
|
-
|
15
|
-
.upmin-model{class: upmin_model.color}
|
16
|
-
-# Display the model title as "Model # ID"
|
1
|
+
.upmin-model{class: model.color}
|
17
2
|
%h3
|
18
|
-
=
|
3
|
+
= model.title
|
19
4
|
|
20
5
|
%br
|
21
6
|
%br
|
22
7
|
%h3{style: "color: #333;"}
|
23
8
|
Attributes
|
24
9
|
%hr
|
25
|
-
-# Create a form to wrap the attributes in.
|
26
|
-
-# TODO(jon): Update the URL with a decent helper?
|
27
|
-
= form_for(upmin_model.instance, url: upmin_model_path(upmin_model.path_hash), html: { method: :put }) do |f|
|
28
|
-
|
29
|
-
-# Render each attribute
|
30
|
-
- upmin_model.klass.attributes.each do |attribute|
|
31
|
-
- any_errors = model.errors[attribute].any?
|
32
|
-
.form-group{class: any_errors ? "has-error" : ""}
|
33
|
-
-# = f.label(attribute.to_s) # Not using this because it drops _id and this isn't always desirable
|
34
|
-
|
35
|
-
%label{for: upmin_model.attribute_form_id(attribute)}
|
36
|
-
= upmin_model.attribute_label_name(attribute)
|
37
|
-
- if upmin_model.attribute_type(attribute) == :string
|
38
|
-
= up_attribute(upmin_model.instance, attribute, locals: { form_builder: f }, as: :nilable)
|
39
|
-
- else
|
40
|
-
= up_attribute(upmin_model.instance, attribute, locals: { form_builder: f })
|
41
10
|
|
11
|
+
.attributes
|
12
|
+
-# Yes this is meant to be model.model - this is the raw rails model instance.
|
13
|
+
= form_for(model, url: model.path, html: { method: :put }) do |f|
|
42
14
|
|
43
|
-
|
15
|
+
-# Render each attribute
|
16
|
+
- model.attributes.each do |attribute|
|
17
|
+
= up_render(attribute, locals: { form_builder: f })
|
44
18
|
|
19
|
+
= f.submit("Save", class: "btn btn-primary")
|
45
20
|
|
46
21
|
|
47
|
-
- if
|
22
|
+
- if model.associations.any?
|
48
23
|
%br
|
49
24
|
%br
|
50
25
|
%br
|
51
26
|
%h3{style: "color: #333;"}
|
52
27
|
Associations
|
53
28
|
%hr
|
54
|
-
|
55
|
-
|
56
|
-
= association
|
57
|
-
= up_association(upmin_model.instance, association, limit: 5)
|
29
|
+
.associations
|
30
|
+
- model.associations.each do |association|
|
31
|
+
= up_render(association)
|
58
32
|
|
59
|
-
|
33
|
+
|
34
|
+
- if model.actions.any?
|
60
35
|
%br
|
61
36
|
%br
|
62
37
|
%br
|
63
38
|
%h3{style: "color: #333;"}
|
64
39
|
Actions
|
65
40
|
%hr
|
66
|
-
|
67
|
-
|
68
|
-
= action
|
69
|
-
= up_action(upmin_model.instance, action)
|
70
|
-
|
71
|
-
|
41
|
+
.actions
|
42
|
+
- model.actions.each do |action|
|
43
|
+
= up_render(action)
|
72
44
|
|
@@ -1,44 +1,22 @@
|
|
1
|
-
-# The following are all available to you here:
|
2
|
-
-# unknown - This is the model passed into the up_model method.
|
3
|
-
-# This attribute is always present in any partial rendered
|
4
|
-
-# by Upmin, and will always match the name of the partial
|
5
|
-
-# *UNLESS* nil, true, or false are passed in.
|
6
|
-
-# upmin_model - This is an Upmin::Model instantiated with unknown
|
7
|
-
-# and is always present.
|
8
|
-
-#
|
9
|
-
-# In general, the upmin_model makes it significantly easier to
|
10
|
-
-# render a view, so I suggest using it. It is way simpler than
|
11
|
-
-# trying to find all associations for a model on your own.
|
12
|
-
-#
|
13
|
-
-# Just an FYI: upmin_model.instance == unknown
|
14
1
|
|
15
|
-
.upmin-model{class:
|
16
|
-
-# Display the model title as "Model # ID"
|
2
|
+
.upmin-model{class: model.color}
|
17
3
|
%h3
|
18
4
|
Create a
|
19
|
-
=
|
5
|
+
= model.humanized_name(:singular)
|
20
6
|
|
21
7
|
%br
|
22
8
|
%br
|
23
9
|
%h3{style: "color: #333;"}
|
24
10
|
Attributes
|
25
11
|
%hr
|
26
|
-
-# Create a form to wrap the attributes in.
|
27
|
-
-# TODO(jon): Update the URL with a decent helper?
|
28
|
-
= form_for(upmin_model.instance, url: upmin_create_model_path(klass: @klass.name), html: { method: :post }) do |f|
|
29
12
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
.form-group{class: any_errors ? "has-error" : ""}
|
34
|
-
-# = f.label(attribute.to_s) # Not using this because it drops _id and this isn't always desirable
|
13
|
+
.attributes
|
14
|
+
-# Yes this is meant to be model.model - this is the raw rails model instance.
|
15
|
+
= form_for(model, url: model.create_path, html: { method: :post }) do |f|
|
35
16
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
= up_attribute(upmin_model.instance, attribute, locals: { form_builder: f }, as: :nilable)
|
40
|
-
- else
|
41
|
-
= up_attribute(upmin_model.instance, attribute, locals: { form_builder: f })
|
17
|
+
-# Render each attribute
|
18
|
+
- model.attributes.each do |attribute|
|
19
|
+
= up_render(attribute, locals: { form_builder: f })
|
42
20
|
|
43
|
-
|
21
|
+
= f.submit("Create", class: "btn btn-primary")
|
44
22
|
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
.form-group
|
2
|
+
%label{for: parameter.form_id}
|
3
|
+
= parameter.label_name
|
4
|
+
|
5
|
+
.input-group
|
6
|
+
= text_field(action.name, parameter.name, class: "form-control")
|
7
|
+
.input-group-addon.nilable-addon
|
8
|
+
.form-group
|
9
|
+
%label{for: parameter.nil_form_id}
|
10
|
+
Do Not Provide
|
11
|
+
= check_box(parameter.action.name, "#{parameter.name}_is_nil", class: "boolean")
|
12
|
+
|
13
|
+
%small
|
14
|
+
* Optional
|
@@ -3,11 +3,10 @@
|
|
3
3
|
= klass.humanized_name
|
4
4
|
|
5
5
|
-# Upmin default search uses the ransack gem, see: https://github.com/activerecord-hackery/ransack
|
6
|
-
= form_tag(
|
6
|
+
= form_tag(klass.search_path, method: :get) do
|
7
7
|
- klass.attributes.each do |attr_name|
|
8
8
|
- type = klass.attribute_type(attr_name)
|
9
9
|
|
10
|
-
-# TODO(jon): Make sure these retain their data on a search
|
11
10
|
-# TODO(jon): Break these into partials possibly?
|
12
11
|
- if type == :string
|
13
12
|
.form-group
|
@@ -34,4 +33,4 @@
|
|
34
33
|
= date_field(:q, "#{attr_name}_lteq", class: "form-control")
|
35
34
|
|
36
35
|
= submit_tag("Search", class: "btn btn-primary btn-block")
|
37
|
-
= link_to("Clear All",
|
36
|
+
= link_to("Clear All", klass.search_path, class: "btn btn-default btn-block")
|