aslon_scaffold 0.0.13 → 0.0.14

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
  SHA1:
3
- metadata.gz: 1495a58ba5db81286d9d2bb7a3d3d018f76656ff
4
- data.tar.gz: bc48789b978fc2dec0b2730995f89963d93cfafc
3
+ metadata.gz: a5ced3021107dd62e0cf5817682ae2e7606f2d09
4
+ data.tar.gz: 89c805a4481c635973857266e57f36a430331645
5
5
  SHA512:
6
- metadata.gz: 1fd63ad125ff6038b5077d29a33908a633f70b5a91b8f8b679ae035f600576e9bc6e471856ffd93a0a2d767fe3cd87d96793fea88a6c14ea073fb8319f54b3f4
7
- data.tar.gz: 044972a85038f773958aa3bc3341c4f04c52131c2dcd2da6487a13f3b6bf01b37ffa30462e156d6ae755ce6482b811229c3b784b5d06b1840a56057096031ec2
6
+ metadata.gz: 01fb5cb684979bcc5d0bcac4eb83668c5fa1d9da754872022740e1e4470bcd03190a12c04ccdfc8162e4d824334eb1620969ecf8002909e28ed2d58ace3142d4
7
+ data.tar.gz: 186f46ead0f2ed90e8cfe19855ab4c2083cce0f9c2924f6d6235a651dd87611e9db99e5367699d7b8f52e00131962a006100bc548a4913d30677079121272165
@@ -53,7 +53,7 @@ module ApplicationHelper
53
53
  end
54
54
  def titre_action (action,model)
55
55
  txt=model_name(model)
56
- ("<h1 class='aslon_scaffold'>"+t("views.generic.#{action}", :model=>txt)+"</h1>").html_safe
56
+ ("<div class='aslon_scaffold'>"+t("views.generic.#{action}", :model=>txt)+"</div>").html_safe
57
57
  end
58
58
 
59
59
  def titre_show(objet, lib)
@@ -68,17 +68,19 @@ module ApplicationHelper
68
68
  end
69
69
 
70
70
  def link_to_image_edit(objet)
71
- if ican? :edit,objet
72
- link_to image_edit,eval("edit_#{objet.class.to_s.underscore.gsub('/','_')}_path(objet)"),:id=>'edit'
71
+ if can? :edit,objet.class
72
+ link_to '<i class="glyphicon glyphicon-pencil"></i> Edit'.html_safe, eval("edit_#{objet.class.to_s.underscore.gsub('/','_')}_path(objet)"), class: 'btn btn-default'
73
73
  end
74
+ # can? :edit,objet.class
74
75
  end
75
76
  def link_to_image_add(objet)
76
- if ican? :create,objet
77
- link_to image_add,eval("new_#{objet.class.to_s.underscore}_path(objet)"),:id=>'add'
77
+ if ican? :create,objet.class
78
+ # link_to image_add,eval("new_#{objet.class.to_s.underscore}_path(objet)"),:id=>'add'
79
+ link_to '<i class="glyphicon glyphicon-plus"></i> Add'.html_safe, eval("new_#{objet.class.to_s.underscore.gsub('/','_')}_path(objet)"), class: 'btn btn-default'
78
80
  end
79
- end
81
+ end
80
82
  def link_to_image_delete(objet)
81
- if ican? :destroy, objet
83
+ if ican? :destroy, objet.class
82
84
  link_to(image_delete, objet, :confirm => 'Are you sure?', :method => :delete, :id=>'delete')
83
85
  end
84
86
  end
@@ -92,10 +94,8 @@ module ApplicationHelper
92
94
  def titre(titre, model=nil, search=true, add=true, action='search',addlink=nil)
93
95
 
94
96
  s=form_tag('javascript:void(0)' )
95
- s="
96
- <table id='titreliste' cellpadding='0' cellspacing='0' >
97
- <tr>
98
- <th COLSPAN='10'>#{titre}"
97
+ # s="#{titre}"
98
+ s=""
99
99
  if add==true
100
100
  if addlink==nil
101
101
  t="new_"+model.singularize.underscore.gsub('/','_') + "_path(:fournisseur_id=>params[:fournisseur_id],
@@ -104,18 +104,20 @@ module ApplicationHelper
104
104
  else
105
105
  t=addlink
106
106
  end
107
- s<<link_to(image_add, eval(t),:id=>'add') if ican?(:create, eval(model.camelcase))
107
+ # s<<link_to(image_add, eval(t),:id=>'add') if ican?(:create, eval(model.camelcase))
108
+ s<<"<form class='form-inline'>"
109
+
110
+ s<<link_to("<i class='glyphicon glyphicon-plus'></i> Add".html_safe, eval(t), class: 'btn btn-default')
108
111
 
109
112
  end
110
113
  if search
111
- s<<" "+image_tag("aslon_scaffold/grid-split.gif", :border=>0, :style=>"vertical-align:middle")
112
- s<<" Search : "
113
- s<< text_field_tag( :search, nil, {:size=>10})
114
+ # s<<" "+image_tag("aslon_scaffold/grid-split.gif", :border=>0, :style=>"vertical-align:middle")
115
+ s<< text_field_tag( :search, nil, {:size=>20,:class=>'form-control',:placeholder=>"Search"})
116
+ s<<"</form>"
114
117
  s<< image_tag("aslon_scaffold/indicator.gif", :style=>"vertical-align:middle", :border => 0, :id => "spiner",:style => "display:none;" )
118
+
115
119
  end
116
- s<<"</th>
117
- </tr>
118
- </table>"
120
+
119
121
  if search
120
122
  cond=":type=>'simle'"
121
123
  # s<< observe_field(:search,
@@ -165,10 +167,11 @@ module ApplicationHelper
165
167
  sel+='&status='+params[:status] if params[:status]
166
168
 
167
169
  wp=will_paginate(table)
168
- info_titre_tableau=page_entries_info(table)
170
+ # info_titre_tableau=page_entries_info(table)
171
+ info_titre_tableau=""
169
172
  s=''.force_encoding('utf-8')
170
173
  # --------------------------------------------------------------------
171
- s<<"<table id='liste'>
174
+ s<<"<table class='table table-responsive table-hover table-striped' id='liste'>
172
175
  <caption>#{info_titre_tableau}</caption>
173
176
  <thead>
174
177
  <tr>"
@@ -222,7 +225,7 @@ module ApplicationHelper
222
225
  id=''
223
226
  c_id=''
224
227
  # ------------- création id de la ligne --------------------------
225
- h.each do |lib|
228
+ h.each do |lib|
226
229
  begin
227
230
  v=eval("aLine."+"#{lib}").to_s
228
231
  rescue
@@ -287,6 +290,135 @@ module ApplicationHelper
287
290
  end
288
291
 
289
292
  end
293
+ def tabledd(model, table, h, actions)
294
+ sel=''
295
+ sel='&type='+params[:type] if params[:type]
296
+ sel+='&status='+params[:status] if params[:status]
297
+
298
+ wp=will_paginate(table)
299
+ info_titre_tableau=page_entries_info(table)
300
+ s=''.force_encoding('utf-8')
301
+ # --------------------------------------------------------------------
302
+ s<<"<tbody><table class='table table-responsive table-hover table-striped' id='liste'>
303
+ <caption>#{info_titre_tableau}</caption>
304
+ <thead>
305
+ <tr>"
306
+ # --------------------------------------------------------------------
307
+ # intitulé des colonnes
308
+ # --------------------------------------------------------------------
309
+
310
+ h.each do |value|
311
+ img='aslon_scaffold/sort_desc.gif'
312
+ sens='DESC'
313
+ if params[:order]==value && params[:sens]=='DESC'
314
+ sens='ASC'
315
+ img='aslon_scaffold/sort_desc.gif'
316
+ end
317
+
318
+ if params[:order]==value && params[:sens]=='ASC'
319
+ sens='DESC'
320
+ img='aslon_scaffold/sort_asc.gif'
321
+ end
322
+ hlib=eval("#{model.gsub('_','/').camelize}.human_attribute_name(value)")
323
+ # sorting doesn't work with search
324
+ if request.env['QUERY_STRING'] != "method=get" && !value.include?('.')
325
+ s<<"<th data-field=#{value} scope='col' onclick=\"self.location.href = \'#{request.env['PATH_INFO']}?#{sel}&order=#{value}&sens=#{sens}\'; \">"
326
+ s<< hlib
327
+ s<<" "+image_tag(img, :border=>0, :style=>"vertical-align:middle") if (img)
328
+ s<<"</th>"
329
+ else
330
+ # s<< "<th scope='col'>"+l(key)+"</th>"
331
+ s<< "<th scope='col'>"+hlib+"</th>"
332
+ end
333
+ end
334
+
335
+ s<<'</tr>'
336
+ s<<'</thead>'
337
+ # --------------------------------------------------------------------
338
+ # bas du tableau
339
+ # --------------------------------------------------------------------
340
+ s<< " <tfoot>
341
+ <tr>
342
+ <th scope='row'>#{info_titre_tableau}</th>
343
+ <td colspan='#{h.size-1}'>&nbsp; #{wp}</td>
344
+ </tr>
345
+ </tfoot>"
346
+ # s<<'</tbody>'
347
+ # --------------------------------------------------------------------
348
+ # lignes du tableau
349
+ # --------------------------------------------------------------------
350
+ i=1
351
+ script="".force_encoding('utf-8')
352
+ for aLine in table
353
+ id=''
354
+ c_id=''
355
+ # ------------- création id de la ligne --------------------------
356
+ h.each do |lib|
357
+ begin
358
+ v=eval("aLine."+"#{lib}").to_s
359
+ rescue
360
+ v='nil'
361
+ end
362
+ id<<model+'_'+lib+'_'+ v.gsub(' ', '')
363
+ c_id=aLine.id
364
+
365
+ end
366
+ # ----------------------------------------------------------------
367
+ # ----------------------------------------------------------------
368
+ if i%2==0
369
+ s<<"<tr id='#{id}' class=#{c_id}>"
370
+ else
371
+ s<<"<tr class='odd #{c_id}' id='#{id}'>"
372
+ end
373
+ i+=1
374
+ # ----------------------------------------------------------------
375
+ cp=0
376
+
377
+ h.each do |lib|
378
+
379
+ local= I18n.locale
380
+ begin
381
+ v=url(eval("aLine."+"#{lib}").to_s)
382
+ rescue
383
+ v='nil'
384
+ end
385
+ s<<""
386
+ premiere_colonne=v
387
+ t=model.singularize.downcase + "_url(aLine)"
388
+ if cp==0
389
+ s<<("<th scope='row' "+"class='"+model.singularize.downcase+'_'+lib+'_'+ v+'_'+"'>" )
390
+ premiere_colonne= link_to(v, eval(t),:id=>'show')
391
+ else
392
+ s<<('<td '+"class='"+model+'_'+lib.to_s+'_'+ v+'_'+local.to_s+"'>")
393
+ end
394
+
395
+ s<< premiere_colonne
396
+ lik= url_for( eval(t))
397
+ # script << "<script>$('#{id}').observe('click',function(e) {window.location='#{lik}';},false)</script>"
398
+ # script << "<script>$('#{id}').observe('click',function(e) {window.location='#{lik}';},false)</script>"
399
+ # script << "<script>$('##{id}').click(function(){window.location='#{lik}';})</script>"
400
+ script << "<script>$('.#{c_id}').click(function(){window.location='#{lik}';})</script>"
401
+ if cp==0
402
+ s<<"&nbsp;</th>"
403
+ else
404
+ s<<"&nbsp;</td>"
405
+ end
406
+ cp+=1
407
+ end
408
+ s<<'</tr>'
409
+
410
+ end
411
+
412
+ s<<"</table>"
413
+ s<<'</tbody>'
414
+ s<<script
415
+ if table.size>0
416
+ return s
417
+ else
418
+ return "0 line"
419
+ end
420
+
421
+ end
290
422
 
291
423
  #todo rendre multiplangues
292
424
  def l(lib)
@@ -1,4 +1,7 @@
1
- =titre_action(controller.action_name,@model_name)
2
- =titre(eval("#{@model_name}.to_s.pluralize"),@model_name,search=true)
3
- #ajaxw
4
- =render :partial=>'aslon_scaffolds/search'
1
+ .panel.panel-default
2
+ .panel-heading
3
+ .panel-title
4
+ =titre_action(controller.action_name,@model_name)
5
+ =titre(eval("#{@model_name}.to_s.pluralize"),@model_name,search=true)
6
+ #ajaxw
7
+ =render :partial=>'aslon_scaffolds/search'
@@ -49,7 +49,7 @@ require "dynamic_form"
49
49
 
50
50
  class ActiveRecord::Base
51
51
  cattr_reader :per_page
52
- @@per_page = 30
52
+ @@per_page = 3
53
53
 
54
54
  def to_label
55
55
  begin
@@ -194,9 +194,10 @@ def search
194
194
  last_part_condition=", '%#{params[:search]}%'"
195
195
  all_part_condition= "' (#{first_part_condition}) and (#{condition}) '" +last_part_condition*search_field.size
196
196
 
197
- eval "@#{objet_name.pluralize}=#{model_name}.paginate(:page => params[:page], :conditions => [#{all_part_condition}], :order=>'id')"
197
+ # eval "@#{objet_name.pluralize}=#{model_name}.paginate(:page => params[:page], :conditions => [#{all_part_condition}], :order=>'id')"
198
+ eval "@#{objet_name.pluralize}=#{model_name}.where(#{all_part_condition}).order('id').limit(30).page(params[:page])"
198
199
 
199
- aslon_render_partial('search')
200
+ aslon_render_partial('search')
200
201
  end
201
202
 
202
203
  # private
@@ -226,7 +227,7 @@ def search
226
227
  render :partial=>"#{action}", :layout=>false
227
228
 
228
229
  rescue
229
- # render :partial=>"aslon_scaffolds/#{action}", :layout=>false
230
+ render :partial=>"aslon_scaffolds/#{action}", :layout=>false
230
231
  end
231
232
  end
232
233
  end
@@ -1,4 +1,4 @@
1
1
  module AslonScaffold
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
 
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aslon_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - alson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-09 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: will_paginate