spiderfw 0.6.21 → 0.6.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/CHANGELOG +33 -0
  2. data/Rakefile +0 -1
  3. data/VERSION +1 -1
  4. data/apps/core/admin/_init.rb +4 -0
  5. data/apps/core/admin/admin.rb +20 -4
  6. data/apps/core/admin/controllers/admin_controller.rb +63 -4
  7. data/apps/core/admin/controllers/app_admin_controller.rb +15 -0
  8. data/apps/core/admin/data/locale/it/LC_MESSAGES/admin.mo +0 -0
  9. data/apps/core/admin/po/admin.pot +33 -0
  10. data/apps/core/admin/po/it/admin.po +34 -0
  11. data/apps/core/admin/public/css/admin.css +13 -0
  12. data/apps/core/admin/public/css/login.css +51 -0
  13. data/apps/core/admin/public/css/sass/admin.css +198 -0
  14. data/apps/core/admin/public/css/sass/bootstrap/bootstrap.css +3107 -0
  15. data/apps/core/admin/public/img/css/header_bg.png +0 -0
  16. data/apps/core/admin/public/img/css/noise.png +0 -0
  17. data/apps/core/admin/public/img/css/side_bg.png +0 -0
  18. data/apps/core/admin/public/img/icons/logout.png +0 -0
  19. data/apps/core/admin/public/img/icons-s845a69dd9f.png +0 -0
  20. data/apps/core/admin/public/js/bootstrap-alerts.js +113 -0
  21. data/apps/core/admin/public/js/bootstrap-buttons.js +62 -0
  22. data/apps/core/admin/public/js/bootstrap-dropdown.js +55 -0
  23. data/apps/core/admin/public/js/bootstrap-modal.js +260 -0
  24. data/apps/core/admin/public/js/bootstrap-popover.js +90 -0
  25. data/apps/core/admin/public/js/bootstrap-scrollspy.js +107 -0
  26. data/apps/core/admin/public/js/bootstrap-tabs.js +80 -0
  27. data/apps/core/admin/public/js/bootstrap-twipsy.js +321 -0
  28. data/apps/core/admin/public/sass/admin.scss +167 -0
  29. data/apps/core/admin/public/sass/bootstrap/bootstrap.scss +29 -0
  30. data/apps/core/admin/public/sass/bootstrap/forms.scss +478 -0
  31. data/apps/core/admin/public/sass/bootstrap/mixins.scss +220 -0
  32. data/apps/core/admin/public/sass/bootstrap/patterns.scss +1062 -0
  33. data/apps/core/admin/public/sass/bootstrap/reset.scss +141 -0
  34. data/apps/core/admin/public/sass/bootstrap/scaffolding.scss +136 -0
  35. data/apps/core/admin/public/sass/bootstrap/tables.scss +224 -0
  36. data/apps/core/admin/public/sass/bootstrap/type.scss +187 -0
  37. data/apps/core/admin/public/sass/bootstrap/variables.scss +60 -0
  38. data/apps/core/admin/public/sass/grid.scss +54 -0
  39. data/apps/core/admin/views/_app_info.shtml +5 -0
  40. data/apps/core/admin/views/admin.layout.shtml +35 -0
  41. data/apps/core/admin/views/index.shtml +1 -1
  42. data/apps/core/admin/views/login.layout.shtml +13 -0
  43. data/apps/core/auth/controllers/mixins/auth_helper.rb +1 -1
  44. data/apps/core/auth/models/super_user.rb +6 -0
  45. data/apps/core/auth/models/user.rb +9 -0
  46. data/apps/core/components/assets.rb +5 -1
  47. data/apps/core/components/data/locale/it/LC_MESSAGES/spider_components.mo +0 -0
  48. data/apps/core/components/po/it/spider_components.po +23 -9
  49. data/apps/core/components/po/spider_components.pot +16 -8
  50. data/apps/core/components/public/css/admin.css +0 -12
  51. data/apps/core/components/public/css/crud.css +16 -19
  52. data/apps/core/components/public/css/table.css +11 -5
  53. data/apps/core/components/public/js/less-1.1.3.min.js +16 -0
  54. data/apps/core/components/public/widgets/table.js +1 -1
  55. data/apps/core/components/widgets/admin/admin.rb +10 -0
  56. data/apps/core/components/widgets/admin/admin.shtml +24 -4
  57. data/apps/core/components/widgets/confirm/confirm.rb +2 -2
  58. data/apps/core/components/widgets/confirm/confirm.shtml +5 -2
  59. data/apps/core/components/widgets/crud/crud.rb +10 -1
  60. data/apps/core/components/widgets/crud/crud.shtml +18 -21
  61. data/apps/core/components/widgets/menu/menu.shtml +1 -2
  62. data/apps/core/components/widgets/switcher/switcher.rb +6 -3
  63. data/apps/core/components/widgets/switcher/templates/default.shtml +3 -1
  64. data/apps/core/components/widgets/table/table.rb +3 -2
  65. data/apps/core/components/widgets/table/table.shtml +44 -25
  66. data/apps/core/forms/data/locale/it/LC_MESSAGES/spider_forms.mo +0 -0
  67. data/apps/core/forms/po/it/spider_forms.po +7 -2
  68. data/apps/core/forms/po/spider_forms.pot +5 -1
  69. data/apps/core/forms/public/css/form.css +3 -3
  70. data/apps/core/forms/public/css/html_area.css +0 -1
  71. data/apps/core/forms/public/date_time.js +4 -3
  72. data/apps/core/forms/public/select.js +5 -4
  73. data/apps/core/forms/tags/element_label.erb +1 -1
  74. data/apps/core/forms/tags/row.erb +1 -1
  75. data/apps/core/forms/widgets/form/form.rb +23 -1
  76. data/apps/core/forms/widgets/form/form.shtml +7 -8
  77. data/apps/core/forms/widgets/inputs/checkbox/checkbox.shtml +3 -3
  78. data/apps/core/forms/widgets/inputs/date_time/date_time.shtml +3 -3
  79. data/apps/core/forms/widgets/inputs/file_input/file_input.rb +4 -2
  80. data/apps/core/forms/widgets/inputs/file_input/file_input.shtml +1 -1
  81. data/apps/core/forms/widgets/inputs/hidden/hidden.shtml +1 -1
  82. data/apps/core/forms/widgets/inputs/html_area/html_area.shtml +2 -2
  83. data/apps/core/forms/widgets/inputs/password/password.shtml +3 -3
  84. data/apps/core/forms/widgets/inputs/search_select/search_select.shtml +2 -2
  85. data/apps/core/forms/widgets/inputs/select/select.shtml +16 -13
  86. data/apps/core/forms/widgets/inputs/text/text.shtml +3 -3
  87. data/apps/core/forms/widgets/inputs/text_area/text_area.shtml +5 -2
  88. data/apps/core/forms/widgets/inputs/time_span/time_span.shtml +3 -3
  89. data/apps/messenger/_init.rb +10 -2
  90. data/apps/messenger/controllers/messenger_admin_controller.rb +53 -0
  91. data/apps/messenger/controllers/messenger_controller.rb +2 -0
  92. data/apps/messenger/controllers/mixins/messenger_helper.rb +2 -2
  93. data/apps/messenger/models/message.rb +1 -1
  94. data/apps/messenger/public/app_icon.png +0 -0
  95. data/apps/messenger/views/admin/_admin.layout.shtml +26 -0
  96. data/apps/messenger/views/admin/index.shtml +13 -0
  97. data/apps/messenger/views/admin/queue.shtml +28 -0
  98. data/apps/messenger/views/index.shtml +3 -3
  99. data/data/locale/it/LC_MESSAGES/spider.mo +0 -0
  100. data/lib/spiderfw/app.rb +10 -1
  101. data/lib/spiderfw/cache/template_cache.rb +21 -22
  102. data/lib/spiderfw/cmd/commands/app.rb +3 -3
  103. data/lib/spiderfw/cmd/commands/setup.rb +1 -1
  104. data/lib/spiderfw/config/options/spider.rb +18 -2
  105. data/lib/spiderfw/controller/controller.rb +9 -3
  106. data/lib/spiderfw/controller/dispatcher.rb +25 -12
  107. data/lib/spiderfw/controller/home_controller.rb +3 -3
  108. data/lib/spiderfw/controller/http_controller.rb +11 -0
  109. data/lib/spiderfw/controller/mixins/static_content.rb +3 -12
  110. data/lib/spiderfw/controller/mixins/visual.rb +21 -20
  111. data/lib/spiderfw/controller/request.rb +1 -3
  112. data/lib/spiderfw/http/adapters/mongrel.rb +1 -1
  113. data/lib/spiderfw/i18n/gettext.rb +14 -0
  114. data/lib/spiderfw/i18n/shtml_parser.rb +2 -2
  115. data/lib/spiderfw/model/base_model.rb +4 -3
  116. data/lib/spiderfw/model/mappers/db_mapper.rb +137 -79
  117. data/lib/spiderfw/model/mappers/mapper.rb +6 -2
  118. data/lib/spiderfw/model/migrations/drop_element.rb +1 -1
  119. data/lib/spiderfw/model/migrations/previous_model.rb +73 -0
  120. data/lib/spiderfw/model/migrations/rename_element.rb +42 -0
  121. data/lib/spiderfw/model/migrations.rb +14 -1
  122. data/lib/spiderfw/model/mixins/tree.rb +65 -19
  123. data/lib/spiderfw/model/model_hash.rb +9 -5
  124. data/lib/spiderfw/model/query.rb +8 -0
  125. data/lib/spiderfw/model/query_funcs.rb +23 -0
  126. data/lib/spiderfw/model/query_set.rb +1 -1
  127. data/lib/spiderfw/model/request.rb +11 -3
  128. data/lib/spiderfw/model/storage/db/adapters/mysql.rb +28 -1
  129. data/lib/spiderfw/model/storage/db/adapters/oracle.rb +10 -10
  130. data/lib/spiderfw/model/storage/db/db_schema.rb +20 -3
  131. data/lib/spiderfw/model/storage/db/db_storage.rb +39 -17
  132. data/lib/spiderfw/setup/app_manager.rb +69 -31
  133. data/lib/spiderfw/setup/setup_task.rb +76 -8
  134. data/lib/spiderfw/spider.rb +21 -1
  135. data/lib/spiderfw/templates/blocks/text.rb +4 -4
  136. data/lib/spiderfw/templates/blocks/text_domain.rb +25 -0
  137. data/lib/spiderfw/templates/blocks/widget.rb +1 -1
  138. data/lib/spiderfw/templates/layout.rb +160 -92
  139. data/lib/spiderfw/templates/resources/less.rb +10 -2
  140. data/lib/spiderfw/templates/resources/sass.rb +66 -9
  141. data/lib/spiderfw/templates/template.rb +35 -10
  142. data/lib/spiderfw/templates/template_blocks.rb +6 -3
  143. data/lib/spiderfw/utils/logger.rb +20 -0
  144. data/lib/spiderfw/utils/memory.rb +7 -3
  145. data/lib/spiderfw/widget/widget.rb +13 -7
  146. data/lib/spiderfw/widget/widget_attributes.rb +2 -2
  147. data/spider.gemspec +1 -0
  148. metadata +68 -11
  149. data/apps/core/admin/views/spider_admin.layout.shtml +0 -23
@@ -1,17 +1,37 @@
1
1
  <div class="{ @widget[:css_class] }">
2
2
  <tpl:assets widgets="core:crud" />
3
3
  <tpl:asset type="css" src="css/admin.css" />
4
- <div class="heading">
4
+ <div class="heading" sp:if="@full_page">
5
5
  <div class="title">
6
6
  <h1>{ @title }</h1>
7
7
  </div>
8
8
  <div class="tools">
9
- Benvenuto, { @username }.
9
+ Benvenuto, { @username }. -
10
10
  <a href="{ @logout_url }" sp:if="!@guest">Logout</a>
11
11
  </div>
12
12
  </div>
13
- <div class="current_section">
13
+ <div class="current_section" sp:if="@full_page">
14
14
  <span id="label">{ @current }</span>
15
15
  </div>
16
- <core:switcher id="switcher" use_template="table" />
16
+ <core:switcher id="switcher">
17
+ <tpl:override-attr name="class" value="spider-admin-container" />
18
+ <tpl:append-attr search=".sidebar" name="class" value="spider-admin-sidebar" />
19
+ <tpl:append-attr search=".content" name="class" value="spider-admin-content" />
20
+ <tpl:prepend search=".sidebar">
21
+ <div sp:if="@_parent && @_parent._parent && @_parent._parent.current_app && @_parent._parent.apps.length > 1"
22
+ class="sidebar-app-info">
23
+ <h2>{ @_parent._parent.current_app[:module].full_name }</h2>
24
+ </div>
25
+ </tpl:prepend>
26
+ <tpl:prepend search=".content">
27
+ <ul class="breadcrumb" sp:if="@_parent._parent.admin_breadcrumb">
28
+ <li sp:each="@_parent._parent.admin_breadcrumb[0..@_parent._parent.admin_breadcrumb.length-2] |bc|">
29
+ <a href="{ bc[:url] }">{ bc[:label] }</a> <span class="divider">/</span>
30
+ </li>
31
+ <li class="active" sp:if="@_parent._parent.admin_breadcrumb.last">
32
+ { @_parent._parent.admin_breadcrumb.last[:label] }
33
+ </li>
34
+ </ul>
35
+ </tpl:prepend>
36
+ </core:switcher>
17
37
  </div>
@@ -12,9 +12,9 @@ module Spider; module Components
12
12
  end
13
13
  end
14
14
 
15
- def add_action(name, value)
15
+ def add_action(name, value, type=nil)
16
16
  @actions ||= []
17
- @actions << [name, value]
17
+ @actions << [name, value, type]
18
18
  end
19
19
 
20
20
  def collapse_params(h, first=true)
@@ -1,9 +1,12 @@
1
1
  <div class="">
2
2
  <form action="{ @request[:path] }" method="POST">
3
3
  <input sp:each="@params |name, value|" type="hidden" name="{ name }" value="{ value }" />
4
- <tpl:placeholder name="text" />
4
+ <p>
5
+ <tpl:placeholder name="text" />
6
+ </p>
5
7
  <div class="actions">
6
- <input sp:each="@actions |action|" type="submit" name="{ action[0] }" value="{ action[1] }" />
8
+ <input sp:each="@actions |action|" type="submit" name="{ action[0] }" value="{ action[1] }"
9
+ class="btn { action[2] }" >
7
10
  </div>
8
11
  </form>
9
12
  </div>
@@ -9,11 +9,20 @@ module Spider; module Components
9
9
  attribute :table_elements
10
10
  i_attr_accessor :table_widget
11
11
  i_attr_accessor :form_widget
12
+ is_attribute :allow_create, :type => Spider::Bool, :default => true
12
13
  attr_accessor :fixed
13
14
 
14
15
  def route_widget
15
16
  [@action, @_action]
16
17
  end
18
+
19
+ def table
20
+ @widgets[:table]
21
+ end
22
+
23
+ def form
24
+ @widgets[:form]
25
+ end
17
26
 
18
27
  def prepare(action='')
19
28
  @action = (@_action_local && !@_action_local.empty?) ? :form : :table
@@ -114,7 +123,7 @@ module Spider; module Components
114
123
  end
115
124
  if @widgets[:ask_delete]
116
125
  @widgets[:ask_delete].add_action('_w'+param_name(self)+'[delete_cancel]', _("Cancel"))
117
- @widgets[:ask_delete].add_action('_w'+param_name(self)+'[do_delete]', _('Ok'))
126
+ @widgets[:ask_delete].add_action('_w'+param_name(self)+'[do_delete]', _('Ok'), "danger")
118
127
  end
119
128
 
120
129
  super
@@ -7,11 +7,6 @@
7
7
  <div sp:if="@deleted" class="flash">
8
8
  Cancellazione effettuata
9
9
  </div>
10
- <div sp:if="@action == :form" class="top">
11
- <a class="back" href="{ @widget[:request_path] }">
12
- Torna all'elenco { @model.label_plural.downcase }
13
- </a>
14
- </div>
15
10
  <core:confirm id="ask_delete" sp:if="@ask_delete">
16
11
  <tpl:content name="text">
17
12
  Sei sicuro di voler cancellare i seguenti elementi?
@@ -23,38 +18,40 @@
23
18
  </tpl:content>
24
19
  </core:confirm>
25
20
  <sp:pass sp:if="!@ask_delete">
26
- <div sp:if="@action == :table" class="top">
27
- <a class="add" href="{ @widget[:request_path] }/new">
28
- Crea nuovo
29
- </a>
30
- </div>
31
- <div class="table_search" sp:if="@action == :table && @show_table_search">
32
- <form action="{ @request[:path] }" method="GET">
33
- <input type="text" name="_w{ param_name(@widget) }[table_q]" value="{ @table_q }">
34
- <input type="submit" name="submit" value="Trova">
35
- <input type="submit" name="_w{ param_name(@widget) }[clear_table_q]" value="Pulisci">
36
- </form>
21
+ <div class="crud-actions">
22
+ <div class="table_search" sp:if="@action == :table && @show_table_search">
23
+ <form action="{ @request[:path] }" method="GET">
24
+ <input type="text" name="_w{ param_name(@widget) }[table_q]" value="{ @table_q }">
25
+ <input type="submit" name="submit" value="Trova">
26
+ <input type="submit" name="_w{ param_name(@widget) }[clear_table_q]" value="Pulisci">
27
+ </form>
28
+ </div>
29
+ <div sp:if="@action == :table && @allow_create" class="add-item">
30
+ <a class="add" href="{ @widget[:request_path] }/new">
31
+ Crea nuovo
32
+ </a>
33
+ </div>
37
34
  </div>
38
35
  <sp:run sp:if="@action == :table && @custom_table" obj="@custom_table" />
39
36
  <core:table sp:if="@action == :table && !@custom_table" id="table" model="@model">
40
- <tpl:override-content search="table .row td">
37
+ <tpl:override-content search="table tbody tr td">
41
38
  <a href="{ @links_to_form[row_i] }" sp:tag-if="element == @key_element"><tpl:overridden /></a>
42
39
  </tpl:override-content>
43
40
  <tpl:append search="table .heading_row">
44
41
  <th>Sel.</th>
45
42
  </tpl:append>
46
- <tpl:override search="table">
43
+ <tpl:override>
47
44
  <form sp:if="@rows && @rows.length > 0" action="{ @request[:path] }" method="POST">
48
45
  <tpl:overridden />
49
46
  <div class="crud_table_actions">
50
- <input type='submit' name="_w{ param_name(@crud) }[delete]" value="Cancella selezionati">
47
+ <input type='submit' class="btn danger" name="_w{ param_name(@crud) }[delete]" value="Cancella selezionati">
51
48
  </div>
52
49
  </form>
53
50
  </tpl:override>
54
- <tpl:append search="table .row">
51
+ <tpl:append search="table tbody tr">
55
52
  <td align="center"><input type='checkbox' name="_w{ param_name(@crud) }[selected][{ @data[row_i][@key_element] }]"></td>
56
53
  </tpl:append>
57
- <tpl:override-attr search="table .paginator td" name="colspan" value="{ elements.size + 1 }" />
54
+ <tpl:override-attr search="table tfoot td" name="colspan" value="{ elements.size + 1 }" />
58
55
  </core:table>
59
56
  <sp:run sp:if="@action == :form && @custom_form" obj="@custom_form" />
60
57
  <forms:form sp:if="@action == :form && !@custom_form" id="form" model="@model" show_related="true" show_additional_buttons="true" />
@@ -1,7 +1,6 @@
1
1
  <div class="{ @widget[:css_class] }">
2
- <tpl:asset type="css" src="css/menu.css" />
3
2
  <sp:pass sp:each="@sections |section_name, items|">
4
- <div class="section_title" sp:if="section_name">{ section_name }</div>
3
+ <h5 class="section_title" sp:if="section_name">{ section_name }</h5>
5
4
  <ul class="section_items">
6
5
  <li sp:each="items |label, target|" class="{ label == @current ? 'active' : 'inactive' }">
7
6
  <a href="{ target }">{ label }</a>
@@ -5,7 +5,7 @@ module Spider; module Components
5
5
 
6
6
  attr_to_scene :current
7
7
  is_attribute :default
8
- attr_reader :current, :current_label
8
+ attr_reader :current, :current_label, :links
9
9
 
10
10
  default_template 'default'
11
11
 
@@ -61,8 +61,7 @@ module Spider; module Components
61
61
 
62
62
  @sections.each do |section, labels|
63
63
  labels.each do |label|
64
- menu_link = @link_mode == :path ? widget_request_path+'/'+@links[label] : "#{widget_request_path}?_wa[#{full_id}]=#{@links[label]}"
65
- @widgets[:menu].add(label, menu_link, section)
64
+ @widgets[:menu].add(label, self.link(label), section)
66
65
  end
67
66
  end
68
67
  @widgets[:menu].current = @current_label
@@ -85,6 +84,10 @@ module Spider; module Components
85
84
  res += @current.assets if @current
86
85
  return res
87
86
  end
87
+
88
+ def link(label)
89
+ @link_mode == :path ? widget_request_path+'/'+@links[label] : "#{widget_request_path}?_wa[#{full_id}]=#{@links[label]}"
90
+ end
88
91
 
89
92
  def self.label_to_link(label)
90
93
  label.downcase.gsub(/\s+/, '_').gsub(/[^a-zA-Z_]/, '')
@@ -1,6 +1,8 @@
1
1
  <div>
2
2
  <tpl:asset type="css" src="css/switcher.css" />
3
- <core:menu id="menu"/>
3
+ <div class="sidebar">
4
+ <core:menu id="menu"/>
5
+ </div>
4
6
  <div id="content" class="content">
5
7
  <sp:render sp:if="@current.is_a?(Spider::Template)" obj="@current" />
6
8
  <sp:run sp:if="@current.is_a?(Spider::Widget)" obj="@current" />
@@ -34,18 +34,19 @@ module Spider; module Components
34
34
  @sort_el = params['sort'].keys.first.to_sym
35
35
  @sort_dir = params['sort'].values.first.to_sym
36
36
  @page = 1
37
+ elsif session[:sort]
38
+ @sort_el, @sort_dir = session[:sort]
37
39
  elsif @attributes[:sort]
38
40
  el, dir = @attributes[:sort].split(',')
39
41
  @sort_el = el.to_sym
40
42
  @sort_dir = dir ? dir.to_sym : :asc
41
43
  end
42
- if (@attributes[:paginate])
44
+ if @attributes[:paginate]
43
45
  @page = params['page'] if params['page']
44
46
  @page ||= 1
45
47
  @page = @page.to_i
46
48
  @offset = ((@page - 1) * @attributes[:row_limit])
47
49
  end
48
- @sort_el, @sort_dir = session[:sort] if !@sort_el && session[:sort]
49
50
  session[:sort] = [@sort_el, @sort_dir] if @sort_el
50
51
  @scene.sorted = {}
51
52
  @scene.sorted[@sort_el] = @sort_dir if @sort_el
@@ -1,10 +1,9 @@
1
1
  <div class="{ @widget[:css_class] }">
2
- <tpl:asset type="css" src="css/table.css" />
3
- <tpl:asset type="js" src="widgets/table.js" />
4
- <table sp:if="@rows && @rows.length > 0" class="{ @widget[:css_class] }">
2
+ <tpl:asset type="js" src="widgets/table.js" />
3
+ <table sp:if="@rows && @rows.length > 0" class="{ @widget[:css_class] }" class="bordered-table zebra-striped">
5
4
  <thead>
6
5
  <tr class="heading_row">
7
- <th sp:each="@elements |element|" class="{ (@sorted[element] ? 'sorted-'+@sorted[element].to_s : '') }">
6
+ <th sp:each="@elements |element|" class="{ @sortable[element] ? 'sortable' : '' } { (@sorted[element] ? 'sorted-'+@sorted[element].to_s : '') }">
8
7
  <a sp:tag-if="@sortable[element]" href="{ @request[:path] }?_w{ @widget[:param] }[sort][{ element }]={ @sorted[element] == :asc ? 'desc' : 'asc' }">
9
8
  { @labels[element] }
10
9
  </a>
@@ -13,7 +12,7 @@
13
12
  </thead>
14
13
  <tbody>
15
14
  <tpl:pass sp:each_index="@rows |row_i|">
16
- <tr class="row { (row_i%2==0) ? 'odd' : 'even' }">
15
+ <tr class="{ (row_i%2==0) ? 'odd' : 'even' }">
17
16
  <td sp:each="@elements |element|">
18
17
  <a sp:tag-if="@link_el && element == @link_el" href="{ @link }{ Spider::HTTP.urlencode(@data[row_i][@link_id]) }">
19
18
  { @rows[row_i][element] }
@@ -22,27 +21,47 @@
22
21
  </tr>
23
22
  </tpl:pass>
24
23
  </tbody>
25
- <tfoot>
26
- <tr class="paginator" sp:if="@paginate && @pages > 1">
27
- <td colspan="{ @columns }" >
28
- <a sp:if="@page > 1" href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @page-1 }">Indietro</a>
29
- <sp:pass sp:if="@paginate_first > 1">
30
- <a href="{ @request[:path] }?_w{ @widget[:param] }[page]=1" class="page">1</a> ...
31
- </sp:pass>
32
- <sp:pass sp:each="(@paginate_first..@paginate_last) |i|" >
33
- <a sp:if="i != @page" href="{ @request[:path] }?_w{ @widget[:param] }[page]={ i }" class="page">
34
- { i }
35
- </a>
36
- <span sp:if="i == @page" class="current">{ i }</span>
37
- </sp:pass>
38
- <sp:pass sp:if="@paginate_last < @pages-1">
39
- ... <a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @pages }" class="page">{ @pages }</a>
40
- </sp:pass>
41
- <a sp:if="@has_more" href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @page+1 }">Avanti</a>
42
- </td>
43
- </tr>
44
- </tfoot>
45
24
  </table>
25
+ <div sp:if="@pages > 1" class="pagination">
26
+ <ul>
27
+ <li sp:if="@page > 1">
28
+ <a class="prev" href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @page-1 }">&larr; _(Previous)</a>
29
+ </li>
30
+ <li sp:if="@page == 1" class="disabled">
31
+ <a class="prev disabled">&larr; _(Previous)</a>
32
+ </li>
33
+ <sp:pass sp:if="@paginate_first > 1">
34
+ <li>
35
+ <a href="{ @request[:path] }?_w{ @widget[:param] }[page]=1" class="page">1</a>
36
+ </li>
37
+ <li class="disabled"><a>...</a></li>
38
+ </sp:pass>
39
+ <sp:pass sp:each="(@paginate_first..@paginate_last) |i|" >
40
+ <li sp:if="i != @page">
41
+ <a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ i }" class="page">
42
+ { i }
43
+ </a>
44
+ </li>
45
+ <li class="active" sp:if="i == @page" >
46
+ <a class="current">{ i }</span>
47
+ </li>
48
+ </sp:pass>
49
+ <sp:pass sp:if="@paginate_last < @pages-1">
50
+ <li class="disabled">
51
+ <a>...</a>
52
+ </li>
53
+ <li>
54
+ <a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @pages }" class="page">{ @pages }</a>
55
+ </li>
56
+ </sp:pass>
57
+ <li sp:if="@has_more">
58
+ <a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @page+1 }">_(Next) &rarr;</a>
59
+ </li>
60
+ <li sp:if="!@has_more" class="disabled">
61
+ <a class="next disabled">_(Next) &rarr;</a>
62
+ </li>
63
+ </ul>
64
+ </div>
46
65
  <div sp:if="!@rows || @rows.length < 1" class="no_result">
47
66
  _(No element)
48
67
  </div>
@@ -6,8 +6,8 @@
6
6
  msgid ""
7
7
  msgstr ""
8
8
  "Project-Id-Version: Spider::Forms 0.1\n"
9
- "POT-Creation-Date: 2011-09-13 14:25+0200\n"
10
- "PO-Revision-Date: 2010-11-29 12:52+0100\n"
9
+ "POT-Creation-Date: 2011-11-15 16:13+0100\n"
10
+ "PO-Revision-Date: 2011-11-15 16:13+0100\n"
11
11
  "Last-Translator: Ivan Pirlik <ivan.pirlik@soluzionipa.it>\n"
12
12
  "Language-Team: LANGUAGE <LL@li.org>\n"
13
13
  "Language: \n"
@@ -32,6 +32,10 @@ msgstr "%s e nuovo"
32
32
  msgid "%s and stay"
33
33
  msgstr "%s e rimani"
34
34
 
35
+ #: widgets/form/form.rb:466
36
+ msgid "New"
37
+ msgstr "Nuovo"
38
+
35
39
  #: widgets/inputs/date_time/date_time.rb:25
36
40
  msgid "%s is not a valid date"
37
41
  msgstr "%s non è una data valida"
@@ -59,3 +63,4 @@ msgstr "Minuti"
59
63
  #: widgets/inputs/time_span/time_span.shtml:6
60
64
  msgid "Hours"
61
65
  msgstr "Ore"
66
+
@@ -7,7 +7,7 @@
7
7
  msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: Spider::Forms 0.1\n"
10
- "POT-Creation-Date: 2011-09-13 14:25+0200\n"
10
+ "POT-Creation-Date: 2011-11-15 16:13+0100\n"
11
11
  "PO-Revision-Date: 2009-06-30 17:03+0200\n"
12
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -33,6 +33,10 @@ msgstr ""
33
33
  msgid "%s and stay"
34
34
  msgstr ""
35
35
 
36
+ #: widgets/form/form.rb:466
37
+ msgid "New"
38
+ msgstr ""
39
+
36
40
  #: widgets/inputs/date_time/date_time.rb:25
37
41
  msgid "%s is not a valid date"
38
42
  msgstr ""
@@ -28,14 +28,14 @@
28
28
  right: 8px;
29
29
  }
30
30
 
31
- .spider.forms.form .row.error label{
31
+ .spider.forms.form .formrow.error label{
32
32
  }
33
33
 
34
- .spider.forms.form .row.error input{
34
+ .spider.forms.form .formrow.error input{
35
35
  background-color: #FF9999;
36
36
  }
37
37
 
38
- .spider.forms.form .row{
38
+ .spider.forms.form .formrow{
39
39
  clear: both;
40
40
  overflow: hidden;
41
41
  margin-top: 5px;
@@ -1,3 +1,2 @@
1
1
  .spider.forms.form div.wdgt-Spider-Forms-HTMLArea{
2
- float: left;
3
2
  }
@@ -4,6 +4,7 @@ Spider.defineWidget('Spider.Forms.DateTime', {
4
4
 
5
5
  ready: function(){
6
6
  var conf = {};
7
+ this.input = this.el.find('input');
7
8
  if (this.el.is('.change-month')) conf.changeMonth = true;
8
9
  if (this.el.is('.change-year')) conf.changeYear = true;
9
10
  var classes = this.el.attr('class').split(' ');
@@ -15,9 +16,9 @@ Spider.defineWidget('Spider.Forms.DateTime', {
15
16
  a = 3;
16
17
  }
17
18
  }
18
- if (this.el.is('.date')) this.el.datepicker(conf);
19
- else if (this.el.is('.date_time')){
20
- var el = this.el;
19
+ if (this.input.is('.date')) this.input.datepicker(conf);
20
+ else if (this.input.is('.date_time')){
21
+ var el = this.input;
21
22
  el.hide();
22
23
  var val = el.val().split(' ');
23
24
  if (!val[1]) val[1] = '';
@@ -3,15 +3,16 @@ Spider.defineWidget('Spider.Forms.Select', 'Spider.Forms.Input', {
3
3
  autoInit: true,
4
4
 
5
5
  ready: function(){
6
- if (this.el.is('select[multiple]')){
7
- this.el.attr('title', 'Aggiungi...');
8
- this.el.bsmSelect({
6
+ var sel = this.el.find('select');
7
+ if (sel.is('select[multiple]')){
8
+ sel.attr('title', 'Aggiungi...');
9
+ sel.bsmSelect({
9
10
  removeLabel: 'togli',
10
11
  highlightAddedLabel: 'Aggiunto: ',
11
12
  highlightRemovedLabel: 'Tolto: ',
12
13
  addItemTarget: 'bottom'
13
14
  });
14
- $('.bsmSelect option:first', this.el.parent()).addClass('bsmSelectTitle')
15
+ $('.bsmSelect option:first', sel.parent()).addClass('bsmSelectTitle')
15
16
  .attr("selected", false)
16
17
  .attr("disabled", true);
17
18
  }
@@ -1,7 +1,7 @@
1
1
  <%
2
2
  @attributes['inputs_hash'] ||= '@inputs'
3
3
  %>
4
- <label for="{ <%=@attributes['inputs_hash']%>[<%=@attributes['element']%>].full_id }">
4
+ <label for="{ <%=@attributes['inputs_hash']%>[<%=@attributes['element']%>].full_id }-input">
5
5
  { <%=@attributes['inputs_hash']%>[<%=@attributes['element']%>].label }
6
6
  <em class="form_required_symbol" sp:if="<%=@attributes['required']%>">*</em>
7
7
  </label>
@@ -10,6 +10,6 @@ else
10
10
  el_class = @attributes['class'] || ''
11
11
  end
12
12
  %>
13
- <div class="row <%=el_class%> { (<%=error_condition%>) ? ' error' : '' }{ (<%=required%>) ? ' required' : '' }">
13
+ <div class="formrow <%=el_class%> { (<%=error_condition%>) ? ' error' : '' }{ (<%=required%>) ? ' required' : '' }">
14
14
  <%=@content%>
15
15
  </div>
@@ -250,7 +250,7 @@ module Spider; module Forms
250
250
  widget_type = el.type.attributes[:estimated_size] && el.type.attributes[:estimated_size] > 30 ?
251
251
  SearchSelect : Select
252
252
  elsif @attributes[:show_related] && @pk && el.multiple?
253
- @sub_links[@pk+'/'+el.label.downcase.gsub(/\s+/, '_')] = @labels[el.name]
253
+ @sub_links[el.name] = sub_link(el)
254
254
  end
255
255
  end
256
256
  input = create_input(widget_type, el) if widget_type
@@ -450,6 +450,28 @@ module Spider; module Forms
450
450
  def disable(*names)
451
451
  @disabled += names
452
452
  end
453
+
454
+ def breadcrumb
455
+ bc = []
456
+ if @obj
457
+ bc << {:label => @obj.to_s, :url => widget_request_path+'/'+@pk}
458
+ if @crud
459
+ sl = sub_link(@sub_element)
460
+ bc << {:label => sl[:label], :url => widget_request_path+'/'+sl[:link] }
461
+ if @crud.action == :form
462
+ bc += @crud.form.breadcrumb
463
+ end
464
+ end
465
+ else
466
+ bc << {:label => _('New'), :url => widget_request_path}
467
+ end
468
+ bc
469
+
470
+ end
471
+
472
+ def sub_link(el)
473
+ {:link => @pk+'/'+el.label.downcase.gsub(/\s+/, '_'), :label => @labels[el.name]}
474
+ end
453
475
 
454
476
 
455
477
  def self.parse_content(doc)
@@ -1,6 +1,5 @@
1
1
  <div class="{ @widget[:css_class] }">
2
2
  <tpl:assets widgets="forms:datetime,forms:file,forms:select,forms:search-select,forms:textarea" />
3
- <tpl:asset type="css" src="css/form.css" />
4
3
  <tpl:asset type="js" src="form.js" />
5
4
  <div sp:if="@error" class='errors'>
6
5
  <ul>
@@ -29,18 +28,18 @@
29
28
  <div class="fields">
30
29
  <forms:element_row sp:each="@names |element|" element="element" required="@inputs[element].required?"/>
31
30
  </div>
32
- <div class="row buttons">
33
- <input type='submit' name='_w{ @widget[:param] }[submit]' value='{ @submit_text }'>
34
- <input type='submit' sp:if="@show_submit_and_stay" name='_w{ @widget[:param] }[submit_and_stay]' value='{ @submit_and_stay_text }'>
35
- <input type='submit' sp:if="@show_submit_and_new" name='_w{ @widget[:param] }[submit_and_new]' value='{ @submit_and_new_text }'>
36
- <input sp:each="@submit_buttons |text|" type='submit' name='_w{ @widget[:param] }[submit]' value='{ text }'>
31
+ <div class="actions">
32
+ <input type='submit' class="btn primary" name='_w{ @widget[:param] }[submit]' value='{ @submit_text }'>
33
+ <input type='submit' sp:if="@show_submit_and_stay" class="btn" name='_w{ @widget[:param] }[submit_and_stay]' value='{ @submit_and_stay_text }'>
34
+ <input type='submit' sp:if="@show_submit_and_new" class="btn" name='_w{ @widget[:param] }[submit_and_new]' value='{ @submit_and_new_text }'>
35
+ <input sp:each="@submit_buttons |text|" type='submit' class="btn" name='_w{ @widget[:param] }[submit]' value='{ text }'>
37
36
  </div>
38
37
  </form>
39
38
  <div class="sub_links" sp:if="!@sub_links.empty?">
40
39
  <h4>Dati collegati:</h4>
41
40
  <ul>
42
- <li sp:each="@sub_links |link, label|">
43
- <a href="{ @widget[:request_path] }/{ link }">{ label }</a>
41
+ <li sp:each="@sub_links |el, l|">
42
+ <a href="{ @widget[:request_path] }/{ l[:link] }">{ l[:label] }</a>
44
43
  </li>
45
44
  </ul>
46
45
  </div>
@@ -1,3 +1,3 @@
1
- <sp:template>
2
- <input type="checkbox" name="{ @name }" value="1" size="{ @size }" sp:attr-if="@value,checked">
3
- </sp:template>
1
+ <div class="input">
2
+ <input type="checkbox" name="{ @name }" id="input" value="1" size="{ @size }" sp:attr-if="@value,checked">
3
+ </div>
@@ -1,6 +1,6 @@
1
- <sp:template>
1
+ <div class="input">
2
2
  <tpl:asset type="js" src="input.js" />
3
3
  <tpl:asset name="jquery-ui-datepicker" />
4
4
  <tpl:asset type="js" src="date_time.js" />
5
- <input type="text" name="{ @name }" value="{ @formatted_value }" size="{ @size }" class="{ @mode } { @additional_classes.join(' ') }">
6
- </sp:template>
5
+ <input type="text" name="{ @name }" id="input" value="{ @formatted_value }" size="{ @size }" class="{ @mode } { @additional_classes.join(' ') }">
6
+ </div>
@@ -7,7 +7,7 @@ module Spider; module Forms
7
7
 
8
8
  class FileInput < Input
9
9
  tag 'file'
10
- is_attr_accessor :save_path, :type => String, :default => lambda{ Spider.paths[:data]+'/uploaded_files' }
10
+ is_attr_accessor :save_path, :type => String, :default => lambda{ Spider.paths[:var]+'/data/uploaded_files' }
11
11
 
12
12
  def needs_multipart?
13
13
  true
@@ -15,7 +15,9 @@ module Spider; module Forms
15
15
 
16
16
  def prepare
17
17
  raise "No save path defined" unless @save_path
18
- raise "Save path #{@save_path} is not a directory" unless File.directory?(@save_path)
18
+ raise "Save path #{@save_path} is not a directory" unless File.directory?(File.dirname(@save_path))
19
+ FileUtils.mkdir_p(@save_path) unless File.directory?(@save_path)
20
+
19
21
  super
20
22
  end
21
23
 
@@ -7,6 +7,6 @@
7
7
  <span class="clear">(<input type="checkbox" name="{ @name }[clear]"> _(Clear))</span>
8
8
  </div>
9
9
  <div class="change"><span sp:if="@value && !@value.to_s.empty?"><span class="change-label">_(Change)</span>:</span>
10
- <input type="file" name="{ @name }[file]" value="{ @value }" size="{ @size }">
10
+ <input type="file" name="{ @name }[file]" id="input" value="{ @value }" size="{ @size }">
11
11
  </div>
12
12
  </div>
@@ -1,3 +1,3 @@
1
1
  <sp:template>
2
- <input type="hidden" name="{ @name }" value="{ @value }">
2
+ <input type="hidden" name="{ @name }" id="input" value="{ @value }">
3
3
  </sp:template>
@@ -1,4 +1,4 @@
1
- <div>
1
+ <div class="input">
2
2
  <tpl:asset type="js" src="ckeditor/ckeditor.js" compressed="true" copy_dir="true"/>
3
3
  <tpl:asset type="js" src="ckeditor/adapters/jquery.js" compressed="true" />
4
4
  <tpl:asset name="jquery" />
@@ -10,5 +10,5 @@
10
10
  <div class="initial_html" style="display:none">{ @initial_html }</div>
11
11
  <div class="css" style="display:none">{ @css }</div>
12
12
  <div class="options" style="display:none">{ @options }</div>
13
- <textarea name="{ @name }" rows="{ @rows }" cols="{ @cols }">{ @value }</textarea>
13
+ <textarea name="{ @name }" id="input" rows="{ @rows }" cols="{ @cols }">{ @value }</textarea>
14
14
  </div>
@@ -1,5 +1,5 @@
1
1
  <div class="input">
2
- <input type="password" name="{ @name }[pwd1]" value="" size="{ @size }"><br>
3
- <div class="notice">Ripeti la password:</div>
4
- <input type="password" name="{ @name }[pwd2]" value="" size="{ @size }"><br>
2
+ <input type="password" name="{ @name }[pwd1]" id="input" value="" size="{ @size }"><br>
3
+ <div class="help-block">Ripeti la password:</div>
4
+ <input type="password" name="{ @name }[pwd2]" id="input2" value="" size="{ @size }"><br>
5
5
  </div>