sinatra-hexacta 1.0.3 → 1.1.4

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: b7b030f298091b86eff87999817b7e167b7f23f70a1cb96cc82571785ab4fecd
4
- data.tar.gz: 89f21adaf020ba14de57ef7b890ae23013bf827e96dd2cf5d6e7cc793d8d42ad
3
+ metadata.gz: 624ee7c381d7793171661f38711d7a3d5b269a9517363d1dab778baee42cf770
4
+ data.tar.gz: 1d47e583f1f8e16f4af003bcc918745f61205b3bcb0a060454e577bcaf6fe2f8
5
5
  SHA512:
6
- metadata.gz: '04543278f129084cd3c67cc5e7aa83ae5c2ee6ef7e9e5cf730927637629b8151384d0fbdc9800e5bf5ccc8748ea3d8ec88fe762289a782c59162ea2b2fc3fc0c'
7
- data.tar.gz: 39ffb8a63ecd557b5700c8b7d8feac27ba97d884e979087fe33e2333bd44990381e2a003c3c2f72e15374d180b8f4f2d06006aa647a13660360250ffbc1d5968
6
+ metadata.gz: 4dd4d4e9749696e47b66409203c82468be0fcc35deecda306e542d4b70c59299f33c676ae246c7f67a323fcc04212f19dd3839769b06f7d4e1c5daebde36f0bb
7
+ data.tar.gz: 64356f393cbe8b8b207fdc8cd63a56ef8038df92e68ab4aa16ca758dbeff0421a8034058e09ae335a4f92ad73acf8c02b3e32010e34d08efb004104ecc4499d1
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+ module Sinatra
3
+ module ConstantHandler
4
+ extend Hexacta
5
+
6
+ def enable_constants
7
+ p "Enabling constants..."
8
+ ConstantHandler.setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/constants")
9
+ ConstantHandler.copy_all_files("/lib/sinatra/views/constants","/app/views/#{Hexacta::GEM_FILE_DIR}/constants")
10
+
11
+ before '/constant*' do
12
+ error(403) if authenticated(User).permissions.empty? && authenticated(User).recruiter.nil?
13
+ end
14
+
15
+ get '/constants' do
16
+ params[:format] = 'group' if params[:format].nil?
17
+ query = Constant.where(:kind => Constant.descendants.collect { |constant_class| constant_class.to_s })
18
+ slim :"#{Hexacta::GEM_FILE_DIR}/constants/#{params[:format]}", locals: { :constants => query.order(:kind,:value).all, :total => query.count, :filters => params, :query => query }
19
+ end
20
+
21
+ post '/constant' do
22
+ attributes = params.select { |attribute| Constant.columns.include?(attribute.to_sym) }
23
+ if params[:values].nil?
24
+ constant = Constant.create(attributes)
25
+ else
26
+ for value in params[:values].split(',')
27
+ attributes[:value] = value
28
+ constant = Constant.find_or_create(attributes)
29
+ end
30
+ end
31
+ redirect back
32
+ end
33
+
34
+ post '/constants/:id' do |id|
35
+ constant = Constant.find(:id => id.to_i)
36
+ constant.update_fields(params, Constant.columns, :missing=>:skip)
37
+ constant.save #This is import to force before save
38
+ redirect back
39
+ end
40
+
41
+ delete '/constants/:id' do |id|
42
+ constant = Constant.find(:id => id.to_i)
43
+ constant.destroy.to_hash.to_json
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ register ConstantHandler
51
+ end
@@ -4,3 +4,4 @@ require_relative 'notifications'
4
4
  require_relative 'params'
5
5
  require_relative 'reports'
6
6
  require_relative 'processes'
7
+ require_relative 'constants'
@@ -1,38 +1,41 @@
1
- .ct-chart.pie id="#{id}"
1
+ -if serie.empty?
2
+ == empty_alert({ :title => "Sin datos suficientes", :message => "No hay suficientes datos para mostrar esta información."})
3
+ -else
4
+ .ct-chart.pie id="#{id}"
2
5
 
3
- .table-responsive.chart-table
4
- table.table.table-striped
5
- tbody
6
- tr
7
- -for label in labels
8
- th #{label}
9
- tr
10
- -for element in serie
11
- td #{element}
12
- tr
13
- -total = [1,serie.reduce(:+)].max
14
- -for element in serie
15
- td #{(element.to_f*100/total).round(0)}%
6
+ .table-responsive.chart-table
7
+ table.table.table-striped
8
+ tbody
9
+ tr
10
+ -for label in labels
11
+ th #{label}
12
+ tr
13
+ -for element in serie
14
+ td #{element}
15
+ tr
16
+ -total = [1,serie.reduce(:+)].max
17
+ -for element in serie
18
+ td #{(element.to_f*100/total).round(0)}%
16
19
 
17
- javascript:
18
- var labels = #{{labels}};
19
- var serie = #{{serie}};
20
+ javascript:
21
+ var labels = #{{labels}};
22
+ var serie = #{{serie}};
20
23
 
21
- new Chartist.Pie("##{id}", {
22
- labels: labels,
23
- series: serie
24
- }, {
25
- fullWidth: true,
26
- showLabel: false,
27
- height: '300px',
28
- plugins: [
29
- Chartist.plugins.legend()
30
- ]
31
- }
32
- );
24
+ new Chartist.Pie("##{id}", {
25
+ labels: labels,
26
+ series: serie
27
+ }, {
28
+ fullWidth: true,
29
+ showLabel: false,
30
+ height: '300px',
31
+ plugins: [
32
+ Chartist.plugins.legend()
33
+ ]
34
+ }
35
+ );
33
36
 
34
- css:
35
- .pie .ct-legend.ct-legend-inside {
36
- position: absolute;
37
- top: 60px;
38
- }
37
+ css:
38
+ .pie .ct-legend.ct-legend-inside {
39
+ position: absolute;
40
+ top: 60px;
41
+ }
@@ -0,0 +1,57 @@
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.action 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
+ == input({ :id => 'edit_value', :name => "value", :title => "Valor", :type => 'text', :value => nil, :required => true })
41
+ .modal-footer
42
+ a.btn.waves-effect.bgm-red#delete.pull-left.c-white Borrar
43
+ button.btn.btn-link.waves-effect data-dismiss="modal" type="button" Cerrar
44
+ button.btn.btn-link.waves-effect type="submit" Actualizar
45
+
46
+
47
+ javascript:
48
+ function editConstant(constant_id,kind,value) {
49
+ $('#edit-constant .action').attr('action', '/constants/' + constant_id);
50
+
51
+ $('#edit-constant #edit_kind').val(kind);
52
+ $('#edit-constant #edit_value').val(value);
53
+
54
+ $('#edit-constant #edit_kind').trigger("chosen:updated");
55
+ $('#edit-constant #delete').attr("onclick","rm_object('constants','"+ constant_id +"')");
56
+ $('#edit-constant').modal('show');
57
+ }
@@ -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.3
4
+ version: 1.1.4
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