sinatra-hexacta 1.0.3 → 1.1.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df6a0ef3c8ba7cdd6d652d08a0c930519dca2aec379bd3275d24fb99f839129e
|
4
|
+
data.tar.gz: c47bab0989ad1a159a308cdc3c229c121293e6d483b14dce97efe0ced18474aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fafe733141d4516b0f0b360097ad195b638fced57dce48fd5fefe1fd0b968ef54afeae4720744827e60ae3742d8ed1870063eb30e9c71c9ee4072ffd9f246353
|
7
|
+
data.tar.gz: d19d3fb7fdc997ad5a4fddefcb1680e4b07e9bc7270b1373617b6688a8ca45ebffd68e706f78bd96ba2acaeff1def4e3488466da11bd53c55dd4b8d0ca3458a1
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Sinatra
|
3
|
+
module ConstantHandler
|
4
|
+
extend Hexacta
|
5
|
+
|
6
|
+
def enable_constants
|
7
|
+
p "Enabling constants..."
|
8
|
+
|
9
|
+
before '/constant*' do
|
10
|
+
error(403) if authenticated(User).permissions.empty? && authenticated(User).recruiter.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
get '/constants' do
|
14
|
+
params[:format] = 'group' if params[:format].nil?
|
15
|
+
query = Constant.where(:kind => Constant.descendants.collect { |constant_class| constant_class.to_s })
|
16
|
+
slim :"#{Hexacta::GEM_FILE_DIR}/constants/#{params[:format]}", locals: { :constants => query.order(:kind,:value).all, :total => query.count, :filters => params, :query => query }
|
17
|
+
end
|
18
|
+
|
19
|
+
post '/constant' do
|
20
|
+
attributes = params.select { |attribute| Constant.columns.include?(attribute.to_sym) }
|
21
|
+
if params[:values].nil?
|
22
|
+
constant = Constant.create(attributes)
|
23
|
+
else
|
24
|
+
for value in params[:values].split(',')
|
25
|
+
attributes[:value] = value
|
26
|
+
constant = Constant.find_or_create(attributes)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
redirect back
|
30
|
+
end
|
31
|
+
|
32
|
+
post '/constants/:id' do |id|
|
33
|
+
constant = Constant.find(:id => id.to_i)
|
34
|
+
constant.update_fields(params, Constant.columns, :missing=>:skip)
|
35
|
+
constant.save #This is import to force before save
|
36
|
+
redirect back
|
37
|
+
end
|
38
|
+
|
39
|
+
delete '/constants/:id' do |id|
|
40
|
+
constant = Constant.find(:id => id.to_i)
|
41
|
+
constant.destroy.to_hash.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
register ConstantHandler
|
49
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
.block-header
|
2
|
+
h2
|
3
|
+
| Constantes
|
4
|
+
|
5
|
+
-grouped_constants = constants.group_by { |constant| constant.kind }
|
6
|
+
-for kind in grouped_constants.keys
|
7
|
+
.card.m-b-5
|
8
|
+
.card-header style="padding: 20px;"
|
9
|
+
.media
|
10
|
+
.media-body.m-t-0
|
11
|
+
.row
|
12
|
+
.col-md-3
|
13
|
+
h2
|
14
|
+
small.m-0 Tipo de constante
|
15
|
+
h5.m-0 #{grouped_constants[kind].first.name}
|
16
|
+
small.m-0 #{grouped_constants[kind].count} valores
|
17
|
+
.col-md-9
|
18
|
+
-for constant in grouped_constants[kind]
|
19
|
+
a.btn.btn-link.bgm-lightgray.m-5.c-gray onclick="editConstant(#{constant.id},'#{constant.kind}','#{constant.value}')"
|
20
|
+
.di-block.v-middle #{constant.value}
|
21
|
+
|
22
|
+
.footer-text
|
23
|
+
a.text.btn.bgm-white.c-gray data-toggle="modal" data-target="#new-constant" Nueva constante
|
24
|
+
|
25
|
+
a.btn.btn-float.bgm-blue.m-btn.waves-effect.waves-circle.waves-float data-toggle="modal" data-target="#new-constant"
|
26
|
+
i.zmdi.zmdi-plus
|
27
|
+
|
28
|
+
== slim :'sinatra-hexacta/constants/new'
|
29
|
+
|
30
|
+
|
31
|
+
.modal.fade id="edit-constant" tabindex="-1" role="dialog" aria-labelledby="editConstant"
|
32
|
+
.modal-dialog
|
33
|
+
form.modal-content method="POST" data-toggle="validator"
|
34
|
+
.modal-content
|
35
|
+
.modal-header
|
36
|
+
h4.modal-title Editar constante
|
37
|
+
.modal-body
|
38
|
+
.row
|
39
|
+
.col-sm-12
|
40
|
+
== select_input({ :id => 'edit_kind', :name => "kind", :elements => [{ :value => nil, :text => 'Elige tipo de constante' }] + (Constant.descendants).collect { |constant_class| { :value => constant_class, :text => constant_class.new.name } }.uniq, :placeholder => "Tipo de constante", :chosen => nil, :required => true })
|
41
|
+
.col-sm-12
|
42
|
+
== input({ :id => 'edit_value', :name => "value", :title => "Valor", :type => 'text', :value => nil, :required => true })
|
43
|
+
.modal-footer
|
44
|
+
a.btn.waves-effect.bgm-red#delete.pull-left.c-white Borrar
|
45
|
+
button.btn.btn-link.waves-effect data-dismiss="modal" type="button" Cerrar
|
46
|
+
button.btn.btn-link.waves-effect type="submit" Actualizar
|
47
|
+
|
48
|
+
|
49
|
+
javascript:
|
50
|
+
function editConstant(constant_id,kind,value) {
|
51
|
+
$('#edit-constant .action').attr('action', '/constants/' + constant_id);
|
52
|
+
|
53
|
+
$('#edit-constant #edit_kind').val(kind);
|
54
|
+
$('#edit-constant #edit_value').val(value);
|
55
|
+
|
56
|
+
$('#edit-constant #edit_kind').trigger("chosen:updated");
|
57
|
+
$('#edit-constant #delete').attr("onclick","rm_object('constants','"+ constant_id +"')");
|
58
|
+
$('#edit-constant').modal('show');
|
59
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
.modal.fade id="new-constant" tabindex="-1" role="dialog" aria-labelledby="newConstant"
|
2
|
+
.modal-dialog.modal-lg
|
3
|
+
.row
|
4
|
+
.col-xs-4
|
5
|
+
form.modal-content action="/constant" method="POST" data-toggle="validator"
|
6
|
+
.modal-content
|
7
|
+
.modal-header
|
8
|
+
h4.modal-title Nueva constante
|
9
|
+
.modal-body
|
10
|
+
.row
|
11
|
+
.col-sm-12
|
12
|
+
== select_input({ :name => "kind", :elements => [{ :value => nil, :text => 'Elige tipo de constante' }] + (Constant.descendants).collect { |constant_class| { :value => constant_class, :text => constant_class.new.name } }.uniq, :placeholder => "Tipo de constante", :selected_elements => nil, :required => true })
|
13
|
+
.col-sm-12
|
14
|
+
== input({:name => "value", :title => "Valor", :type => 'text', :value => '', :required => true })
|
15
|
+
.modal-footer
|
16
|
+
button.btn.btn-link.waves-effect data-dismiss="modal" type="button" Cerrar
|
17
|
+
button.btn.btn-link.waves-effect type="submit" Crear
|
18
|
+
|
19
|
+
.col-xs-8
|
20
|
+
form.modal-content action="/constant" method="POST" data-toggle="validator"
|
21
|
+
.modal-content
|
22
|
+
.modal-header
|
23
|
+
h4.modal-title Nuevas constantes
|
24
|
+
.modal-body
|
25
|
+
.row
|
26
|
+
.col-sm-12
|
27
|
+
== select_input({ :name => "kind", :elements => [{ :value => nil, :text => 'Elige tipo de constante' }] + (Constant.descendants).collect { |constant_class| { :value => constant_class, :text => constant_class.new.name } }.uniq, :placeholder => "Tipo de constante", :selected_elements => nil, :required => true })
|
28
|
+
.col-sm-12
|
29
|
+
== input({:name => "values", :title => "Valores separados por coma", :type => 'text', :value => '', :required => true })
|
30
|
+
.modal-footer
|
31
|
+
button.btn.btn-link.waves-effect data-dismiss="modal" type="button" Cerrar
|
32
|
+
button.btn.btn-link.waves-effect type="submit" Crear
|
33
|
+
br
|
34
|
+
.modal-content
|
35
|
+
== slim info_alert({ :title => 'Creación masiva', :message => "Separa por coma los valores para crear multiples constantes de una sola vez."})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-hexacta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Zanger
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/sinatra/extensions/menu.rb
|
84
84
|
- lib/sinatra/extensions/notification.rb
|
85
85
|
- lib/sinatra/extensions/processmanager.rb
|
86
|
+
- lib/sinatra/handlers/constants.rb
|
86
87
|
- lib/sinatra/handlers/errors.rb
|
87
88
|
- lib/sinatra/handlers/init.rb
|
88
89
|
- lib/sinatra/handlers/notifications.rb
|
@@ -185,6 +186,8 @@ files:
|
|
185
186
|
- lib/sinatra/views/charts/line.slim
|
186
187
|
- lib/sinatra/views/charts/pie.slim
|
187
188
|
- lib/sinatra/views/charts/stacked_bar.slim
|
189
|
+
- lib/sinatra/views/constants/group.slim
|
190
|
+
- lib/sinatra/views/constants/new.slim
|
188
191
|
- lib/sinatra/views/errors/403.slim
|
189
192
|
- lib/sinatra/views/errors/404.slim
|
190
193
|
- lib/sinatra/views/errors/500.slim
|