sunrise-cms 1.1.0 → 1.1.1

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: eead0862b5bf8d42ba5d82e93028451c6c17dddce56299d59018772620942abe
4
- data.tar.gz: eab912f83b38a93e75218863634e6b43ba6a6b070208650998ad65aaac28580d
3
+ metadata.gz: '098ce642eeaa4b3b99e038cac5afe914c4fec9c8e5a89a74454f2fa3bc0e8505'
4
+ data.tar.gz: accfeff359f7db91dee2ad3b186f7b1b93130d6c8e0f716c4e689d32963d9760
5
5
  SHA512:
6
- metadata.gz: 32f253d0e63241684662aa603c9bd070416715c1d67f84cc3856c167c432837f63b9229d5d45f88240489924f59d1f80b3f5184649a90920f79c7ceabae2747f
7
- data.tar.gz: 75332274d7a27769bcdae5dcb476321b8820920700a0c1846b1776ad66f4a25d0a66f0597a5af011a8d73d03cfac7cc61ae7f2476bdc927dfda0d77c1ea99f47
6
+ metadata.gz: d2560918f0f7f7103a48b27b4afc7f753effa7757054f2d1cb8a3f6e3964c987a7183a0f78a43c4950358f9131c0c895160e1b11f0278417ac2cbce622f8711d
7
+ data.tar.gz: '082d6d8027a20ace581d6a1008fe13981ff25198997dd5689383ba09b4ae319ec08db84ee7ccab75d9400a072812da9328dc94c428617af5e38e053a2d98e8ca'
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ spec/dummy/log/development.log
22
22
  vendor/bundle/
23
23
  .DS_Store
24
24
  uploads/
25
+ .byebug_history
data/CHANGELOG.rdoc CHANGED
@@ -1,9 +1,14 @@
1
+ == 1.1.1
2
+ * Update code to be compatible with rails 5.x
3
+ * Import for records functional
4
+ * Remove select2 dependecy
5
+
1
6
  == 1.0.5
2
7
  * Update jQuery UI
3
8
 
4
9
  == 1.0.3
5
10
  * Fix parents relations
6
-
11
+
7
12
  == 1.0.2
8
13
  * Use select2
9
14
  * Remove chosen
@@ -63,10 +68,10 @@
63
68
  * Replace paperclip with carrierwave
64
69
  * New model filter logic
65
70
 
66
- * Scaffold
71
+ * Scaffold
67
72
  * Generate spec tests for controllers
68
73
  * Apply new model filter logic
69
-
74
+
70
75
  == 0.1.5
71
76
  * Core
72
77
  * Export users to csv
data/Gemfile CHANGED
@@ -20,18 +20,22 @@ gem 'galetahub-enum_field', '~> 0.4.0'
20
20
  gem 'rails-settings-cached', '~> 0.4.0'
21
21
  gem 'rails-uploader', '~> 0.3.4'
22
22
 
23
+ gem 'sprockets', '>= 3.0.0', '< 4.0.0'
24
+
23
25
  # Gems used only for assets and not required
24
26
  # in production environments by default.
25
27
  group :assets do
26
28
  gem 'coffee-rails'
27
29
  gem 'sass-rails'
30
+ gem 'sass'
28
31
 
29
32
  gem 'libv8', '~> 3.11.8.4', platforms: :ruby
30
- gem 'therubyracer', platforms: :ruby
31
33
  gem 'uglifier', '>= 1.0.3'
34
+ # gem 'therubyracer', platforms: :ruby
32
35
  end
33
36
 
34
37
  group :development, :test do
38
+ gem 'byebug'
35
39
  gem 'fuubar'
36
40
  gem 'generator_spec', '~> 0.9.4'
37
41
  gem 'launchy'
@@ -43,10 +47,3 @@ group :active_record do
43
47
  gem 'awesome_nested_set'
44
48
  gem 'pg', '~> 0.15'
45
49
  end
46
-
47
- # group :mongoid do
48
- # gem 'bson_ext'
49
- # gem 'carrierwave-mongoid', require: 'carrierwave/mongoid'
50
- # gem 'mongoid', '~> 4.0.2'
51
- # gem 'mongoid_nested_set', '>= 0.2.1'
52
- # end
data/README.md CHANGED
@@ -4,6 +4,12 @@ Open source mini content management system for programmers.
4
4
 
5
5
  ## Setup
6
6
 
7
+ For rails 5.x.x:
8
+
9
+ ```ruby
10
+ gem 'sunrise-cms', '~> 1.1.0', require: 'sunrise'
11
+ ```
12
+
7
13
  For rails 4.x.x:
8
14
 
9
15
  ```ruby
data/Rakefile CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'rake'
4
4
  require 'rake/testtask'
5
5
  require 'rdoc/task'
6
+ require 'bundler/gem_tasks'
6
7
 
7
8
  desc 'Default: run unit tests.'
8
9
  task default: :test
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg id="i-export" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
3
+ <path d="M28 22 L28 30 4 30 4 22 M16 4 L16 24 M8 12 L16 4 24 12" />
4
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32">
2
+ <g fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
3
+ <path d="M28 22 L28 30 4 30 4 22 M16 4 L16 24 M8 16 L16 24 24 16" />
4
+ </g>
5
+ </svg>
@@ -5,7 +5,6 @@
5
5
  //= require jquery-ui/datepicker
6
6
  //= require datepicker/jquery.ui.datepicker-uk
7
7
  //= require datepicker/jquery.ui.datepicker-ru
8
- //= require select2
9
8
 
10
9
  //= require sunrise/jquery.tmpl.min
11
10
  //= require sunrise/jquery.cookie
@@ -7,130 +7,203 @@ $.fn.extend({
7
7
  )
8
8
  })
9
9
 
10
+ $.fn.extend({
11
+ import_dialog: (options) ->
12
+ $(this).each((input_field) ->
13
+ new ImportDialog(this, options) unless ($ this).hasClass "dialog-init"
14
+ )
15
+ })
16
+
10
17
  class Dialog
11
- constructor: (@form_field, options = {}) ->
18
+ constructor: (@form_field, options = {}) ->
12
19
  defaults =
13
20
  shadow_field: "#dark-shadow"
14
21
  dialog_class: "sunrise-dialog"
15
-
22
+
16
23
  @options = $.extend defaults, options
17
-
24
+
18
25
  this.setup()
19
26
  this.register_observers()
20
-
27
+
21
28
  setup: ->
22
29
  dom_id = this.generate_random_id()
23
30
  @element = $ @form_field
24
-
31
+
25
32
  @shadow = $ @options.shadow_field
26
33
  @container = $ '<div/>', { id: dom_id, class: @options.dialog_class }
27
- @container.hide()
34
+ @container.hide()
28
35
  @shadow.after @container
29
-
36
+
30
37
  @element.addClass "dialog-init"
31
-
38
+
32
39
  register_observers: ->
33
40
  @shadow.bind 'click', (evt) => this.hide()
34
- @element.bind 'click', (evt) =>
41
+ @element.bind 'click', (evt) =>
35
42
  this.show()
36
43
  false
37
-
44
+
38
45
  show: ->
39
46
  wnd = $(window)
40
47
  body = $('body')
41
-
48
+
42
49
  height = if body.innerHeight() > wnd.innerHeight() then body.innerHeight() else wnd.innerHeight()
43
50
  @shadow.css 'height', height + 'px'
44
51
  @container.css 'left', ($(window).innerWidth() - @container.innerWidth()) / 2 + 'px'
45
-
52
+
46
53
  @shadow.show()
47
54
  @container.show()
48
-
55
+
49
56
  hide: ->
50
57
  @shadow.hide()
51
58
  @container.hide()
52
-
59
+
53
60
  generate_random_id: ->
54
61
  string = "dlg_" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char()
55
62
  while $("#" + string).length > 0
56
63
  string += this.generate_random_char()
57
64
  string
58
-
65
+
59
66
  generate_random_char: ->
60
67
  chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ"
61
68
  rand = Math.floor(Math.random() * chars.length)
62
69
  newchar = chars.substring rand, rand+1
63
-
64
-
70
+
71
+ # SORT
65
72
  class SortDialog extends Dialog
66
-
73
+
67
74
  setup: ->
68
75
  super
69
-
76
+
70
77
  @container.addClass 'sort-wrapper'
71
-
78
+
72
79
  title = $('<div/>', { class: 'sort-title' })
73
80
  title.text(@element.attr 'title')
74
-
81
+
75
82
  buttons_holder = $ '<div/>', { class: 'sort-buts-holder' }
76
83
  @save_button = $ '<input/>', { type: 'submit', value: @element.data('save_title'), class: 'button', disabled: 'disabled'}
77
84
  @cancel_button = $ '<input/>', { type: 'submit', value: @element.data('cancel_title'), class: 'button gray'}
78
-
85
+
79
86
  buttons_holder.append(@save_button).append(@cancel_button)
80
87
  title_holder = $ '<div/>', { class: 'sort-title-holder' }
81
88
  title_holder.append(title).append(buttons_holder)
82
-
89
+
83
90
  items_container = $ '<div/>', { class: 'sort-items-holder', id: 'sort_items' }
84
-
91
+
85
92
  @container.append(title_holder).append(items_container)
86
-
93
+
87
94
  register_observers: ->
88
95
  super
89
-
96
+
90
97
  @cancel_button.bind 'click', (evt) => this.hide()
91
98
  @save_button.bind 'click', (evt) => this.save(evt)
92
-
99
+
93
100
  show: ->
94
101
  super
95
- this.load_data()
96
-
102
+ this.load_data()
103
+
97
104
  save: ->
98
105
  items = {}
99
106
  klass = this
100
-
107
+
101
108
  $('.sort-item').each (index) ->
102
109
  items['ids[' + $(this).data('record-id') + ']'] = index + 1
103
-
110
+
104
111
  $.rails.ajax
105
112
  url: @element.data 'url'
106
113
  type: 'POST'
107
114
  data: items
108
115
  success: ->
109
116
  klass.hide()
110
-
117
+
111
118
  load_data: ->
112
119
  klass = this
113
-
120
+
114
121
  $.ajax
115
122
  url: @element.attr 'href'
116
123
  success: (data, status, xhr) ->
117
124
  $('#sort_items').empty()
118
125
  $("#sort-template" ).tmpl(data).appendTo('#sort_items')
119
126
  # klass.refresh_counters()
120
-
127
+
121
128
  $("#sort_items").sortable
122
129
  cursor: 'crosshair'
123
130
  opacity: 0.6
124
- update: (event, ui) ->
131
+ update: (event, ui) ->
125
132
  klass.update_sort_item(event, ui)
126
-
133
+
127
134
  refresh_counters: ->
128
135
  $('.sort-item .numb').each (index) ->
129
136
  $(this).text index + 1
130
-
137
+
131
138
  update_sort_item: (event, ui) ->
132
139
  @save_button.attr 'disabled', false
133
140
  this.refresh_counters()
134
-
135
-
136
-
141
+
142
+ # IMPORT
143
+ class ImportDialog extends Dialog
144
+ setup: ->
145
+ super
146
+
147
+ @container.addClass 'import-wrapper'
148
+
149
+ title = $('<div/>', { class: 'import-title' })
150
+ title.text(@element.data('title'))
151
+
152
+ @upload_input = $('<input />', { type: 'file', class: 'import-fileupload' })
153
+ @records_list = $('<ul/>')
154
+
155
+ @upload_input.fileupload
156
+ url: @element.data('url')
157
+ dataType: 'json'
158
+ autoUpload: true
159
+ uploadTemplateId: false
160
+ downloadTemplateId: false
161
+ done: (e, data) =>
162
+ $.each data.result.files, (findex, file) =>
163
+ $.each file.records, (rindex, record) =>
164
+ line = $('<li>')
165
+
166
+ if record?.html?
167
+ line.append(record.html)
168
+ else
169
+ if record.errors?.length > 0
170
+ rrr = $.extend({}, record)
171
+ delete(rrr.row)
172
+ delete(rrr.errors)
173
+ line.addClass('import-invalid-error')
174
+ line.append($("<b>ROW: #{record.row}</b>"))
175
+ line.append($('<br/>')).append(JSON.stringify(rrr)).append($('<br/>'))
176
+ line.append(record.errors.join('<br/>'))
177
+ else
178
+ line.append($("<b>ROW: #{record.row}</b>"))
179
+ line.append($('<br/>'))
180
+ line.append JSON.stringify(record)
181
+
182
+ @records_list.append(line)
183
+
184
+ @container.addClass('disabled')
185
+ $("#records").load "#{location.pathname} #records", =>
186
+ @container.removeClass('disabled')
187
+
188
+ buttons_holder = $ '<div/>', { class: 'import-buts-holder' }
189
+ @close_button = $ '<input/>', { type: 'reset', value: 'Close', class: 'button gray'}
190
+
191
+ buttons_holder.append(@save_button).append(@close_button)
192
+ title_holder = $ '<div/>', { class: 'import-title-holder' }
193
+ title_holder.append(title).append(@upload_input).append(buttons_holder)
194
+
195
+ items_container = $ '<div/>', { class: 'import-items-holder', id: 'import_items' }
196
+ items_container.append(@records_list)
197
+
198
+ @container.append(title_holder).append(items_container)
199
+
200
+ register_observers: ->
201
+ super
202
+
203
+ @close_button.bind 'click', (evt) =>
204
+ # this.hide()
205
+ # location?.reload?()
206
+ # @records_list.empty()
207
+ this.hide()
208
+ @records_list.empty()
209
+
@@ -9,67 +9,67 @@ class Editable
9
9
  constructor: (@fields, options = {}) ->
10
10
  this.setup()
11
11
  this.register_observers()
12
-
12
+
13
13
  setup: ->
14
14
  @elements = $ @fields
15
15
  @delete_button = @elements.filter('[data-editable=destroy]').first()
16
16
  @edit_button = @elements.filter('[data-editable=edit]').first()
17
-
18
- register_observers: ->
17
+
18
+ register_observers: ->
19
19
  @elements.bind 'click', (evt) =>
20
20
  element = $(evt.target)
21
-
21
+
22
22
  unless element.hasClass('disabled')
23
23
  switch element.data('editable')
24
24
  when 'destroy' then this.destroy(element)
25
25
  when 'edit' then this.edit(element)
26
26
  false
27
-
27
+
28
28
  $('.check-block input').bind 'change', (evt) =>
29
29
  this.check_buttons()
30
-
30
+
31
31
  $('.but-holder .check input').bind 'change', (evt) =>
32
32
  $('.check-block input').prop("checked", $(evt.target).prop("checked"))
33
33
  this.check_buttons()
34
-
34
+
35
35
  check_buttons: ->
36
- count = $('.check-block input:checked').size()
37
-
36
+ count = $('.check-block input:checked').length
37
+
38
38
  this.toggle_button count > 0, @delete_button
39
39
  this.toggle_button count == 1, @edit_button
40
-
40
+
41
41
  toggle_button: (condition, button) ->
42
42
  if condition then button.removeClass('disabled') else button.addClass('disabled')
43
-
43
+
44
44
  destroy: (element) ->
45
45
  if this.allowAction(@delete_button)
46
46
  this.handleMethod(element, 'delete')
47
-
47
+
48
48
  edit: (element) ->
49
49
  item = $('.check-block input:checked').first()
50
50
  location = element.attr('href').replace('0', item.val())
51
51
  window.location = location
52
-
52
+
53
53
  allowAction: (element) ->
54
- message = element.data('confirm-message')
54
+ message = element.data('confirm-message') || element.data('confirm')
55
55
  answer = false
56
- # callback;
57
- if !message
58
- return true
56
+ callback = undefined
57
+
58
+ return true unless message
59
59
 
60
- if $.rails.fire(element, 'confirm')
60
+ if $.rails.fire(element, 'confirm')
61
61
  answer = $.rails.confirm(message)
62
62
  callback = $.rails.fire(element, 'confirm:complete', [answer])
63
-
63
+
64
64
  answer && callback
65
-
65
+
66
66
  handleMethod: (link, method) ->
67
67
  href = link.attr('href')
68
68
  csrf_token = $('meta[name=csrf-token]').attr('content')
69
69
  csrf_param = $('meta[name=csrf-param]').attr('content')
70
70
  form = $('<form method="post" action="' + href + '"></form>')
71
71
  metadata_input = '<input name="_method" value="' + method + '" type="hidden" />'
72
-
72
+
73
73
  $('.check-block input:checked').each (index, element) ->
74
74
  metadata_input += '<input name="ids[]" value="' + $(element).val() + '" type="hidden" />'
75
75