knitkit 2.1.12 → 2.1.13

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.
@@ -29,25 +29,26 @@ class Content < ActiveRecord::Base
29
29
  def self.search(options = {})
30
30
  predicate = Content.includes([:website_sections])
31
31
 
32
- if options[:section_unique_name]
32
+ unless options[:section_unique_name].blank?
33
33
  predicate = predicate.where("website_sections.internal_identifier = ?", options[:section_unique_name])
34
34
  end
35
35
 
36
- if options[:parent_id]
36
+ unless options[:parent_id].blank?
37
37
  predicate = predicate.where("website_sections.id" => WebsiteSection.find(options[:parent_id]).self_and_descendants.collect(&:id))
38
38
  end
39
39
 
40
- if options[:content_type]
40
+ unless options[:content_type].blank?
41
41
  predicate = predicate.where("website_sections.type = ?", options[:content_type])
42
42
  end
43
43
 
44
- if options[:website_id]
44
+ unless options[:website_id].blank?
45
45
  predicate = predicate.where("website_sections.website_id = ?", options[:website_id])
46
46
  end
47
47
 
48
48
  predicate = predicate.where("(UPPER(contents.title) LIKE UPPER('%#{options[:query]}%')
49
49
  OR UPPER(contents.excerpt_html) LIKE UPPER('%#{options[:query]}%')
50
50
  OR UPPER(contents.body_html) LIKE UPPER('%#{options[:query]}%') )").order("contents.created_at DESC")
51
+
51
52
  if options[:page]
52
53
  predicate.paginate(:page => options[:page], :per_page => options[:per_page])
53
54
  else
@@ -12,7 +12,7 @@ class Website < ActiveRecord::Base
12
12
  friendly_id :name, :use => [:slugged], :slug_column => :internal_identifier
13
13
 
14
14
  def should_generate_new_friendly_id?
15
- new_record?
15
+ new_record? and self.internal_identifier.nil?
16
16
  end
17
17
 
18
18
  has_many :published_websites, :dependent => :destroy
@@ -301,9 +301,6 @@ class Website < ActiveRecord::Base
301
301
  File.open(tmp_dir + 'setup.yml', 'wb+') { |f| f.puts(export_setup.to_yaml) }
302
302
 
303
303
  (tmp_dir + "#{name}.zip").tap do |file_name|
304
- Rails.logger.info "@@@@@@@@@@@@@@@"
305
- Rails.logger.info file_name.inspect
306
- Rails.logger.info "@@@@@@@@@@@@@@@"
307
304
  file_name.unlink if file_name.exist?
308
305
  Zip::ZipFile.open(file_name.to_s, Zip::ZipFile::CREATE) do |zip|
309
306
  files.each { |file| zip.add(file[:name], file[:path]) if File.exists?(file[:path]) }
@@ -86,13 +86,15 @@ module Widgets
86
86
 
87
87
  def update_password
88
88
  if @user = User.authenticate(current_user.username, params[:old_password])
89
+ load_profile_data
90
+
89
91
  if !params[:new_password].blank? && !params[:password_confirmation].blank? && params[:new_password] == params[:password_confirmation]
90
92
 
91
93
  @user.password_confirmation= params[:password_confirmation]
92
94
 
93
95
  if @user.change_password!(params[:new_password])
94
96
  @message = "Password Updated"
95
- load_profile_data
97
+
96
98
  render :update => {:id => "#{@uuid}_result", :view => :index}
97
99
  else
98
100
  @message = "Error Updating Password"
@@ -108,6 +110,7 @@ module Widgets
108
110
  render :update => {:id => "#{@uuid}_result", :view => :index}
109
111
  end
110
112
  else
113
+ load_profile_data
111
114
  #### old password wrong ####
112
115
  @message = "Invalid Old Password"
113
116
  @message_cls = 'sexyerror'
@@ -10,7 +10,7 @@ module Knitkit
10
10
  config.knitkit = Knitkit::Config
11
11
 
12
12
  initializer "knikit.merge_public" do |app|
13
- app.middleware.insert_before Rack::Lock, ::ActionDispatch::Static, "#{root}/public"
13
+ app.middleware.insert_before Rack::Runtime, ::ActionDispatch::Static, "#{root}/public"
14
14
  end
15
15
 
16
16
  ActiveSupport.on_load(:active_record) do
@@ -45,13 +45,15 @@ module Knitkit
45
45
  order(:position).all
46
46
  published_contents = []
47
47
  section_contents.each do |sc|
48
- content_version = Content.get_published_version(@active_publication, sc.content)
48
+ content_version = Content.get_published_version(@active_publication, sc.content) unless @active_publication.nil?
49
+ content_version = sc.content if @active_publication.nil? or content_version.nil?
49
50
  published_contents << content_version unless content_version.nil?
50
51
  end
51
52
 
52
53
  published_contents.each do |content|
54
+ content_id = content.content.id rescue content.id
53
55
  html << "<div class='knitkit_content'
54
- contentid='#{content.content.id}'
56
+ contentid='#{content_id}'
55
57
  lastupdate='#{content.updated_at.strftime("%m/%d/%Y %I:%M%p")}'>
56
58
  #{(content.body_html.nil? ? '' : content.body_html)}</div>"
57
59
 
@@ -2,7 +2,7 @@ module Knitkit
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 1
5
- TINY = 12
5
+ TINY = 13
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
@@ -1,234 +1,237 @@
1
1
  Compass.ErpApp.Desktop.Applications.Knitkit.addWebsiteNavItemOptions = function (self, items, record) {
2
- if (currentUser.hasCapability('edit','WebsiteNavItem'))
3
- {
4
- items.push({
5
- text:'Update Menu Item',
6
- iconCls:'icon-edit',
7
- handler:function(btn){
8
- var addMenuItemWindow = Ext.create("Ext.window.Window",{
9
- layout:'fit',
10
- width:375,
11
- title:'Update Menu Item',
12
- height:175,
13
- plain: true,
14
- buttonAlign:'center',
15
- items: Ext.create('Ext.form.Panel',{
16
- labelWidth: 50,
17
- frame:false,
18
- bodyStyle:'padding:5px 5px 0',
19
- url:'/knitkit/erp_app/desktop/website_nav/update_menu_item',
20
- defaults: {
21
- width: 225
22
- },
23
- items: [
24
- {
25
- xtype:'textfield',
26
- fieldLabel:'Title',
27
- value:record.data.text,
28
- allowBlank:false,
29
- name:'title'
30
- },
31
- {
32
- xtype:'combo',
33
- fieldLabel:'Link to',
34
- name:'link_to',
35
- id:'knitkit_nav_item_link_to',
36
- allowBlank:false,
37
- forceSelection:true,
38
- editable:false,
39
- autoSelect:true,
40
- typeAhead: false,
41
- mode: 'local',
42
- triggerAction: 'all',
43
- store:[
44
- ['website_section','Section'],
45
- //['article','Article'],
46
- ['url','Url']
47
-
48
- ],
49
- value:record.data.linkToType,
50
- listeners:{
51
- 'change':function(combo, newValue, oldValue){
52
- switch(newValue){
53
- case 'website_section':
54
- Ext.getCmp('knitkit_website_nav_item_section').show();
55
- //Ext.getCmp('knitkit_website_nav_item_article').hide();
56
- Ext.getCmp('knitkit_website_nav_item_url').hide();
57
- break;
58
- case 'article':
59
- Ext.getCmp('knitkit_website_nav_item_section').hide();
60
- //Ext.getCmp('knitkit_website_nav_item_article').show();
61
- Ext.getCmp('knitkit_website_nav_item_url').hide();
62
- break;
63
- case 'url':
64
- Ext.getCmp('knitkit_website_nav_item_section').hide();
65
- //Ext.getCmp('knitkit_website_nav_item_article').hide();
66
- Ext.getCmp('knitkit_website_nav_item_url').show();
67
- break;
68
- }
69
- }
70
- }
71
- },
72
- {
73
- xtype:'combo',
74
- width:300,
75
- id:'knitkit_website_nav_item_section',
76
- hiddenName:'website_section_id',
77
- name:'website_section_id',
78
- loadingText:'Retrieving Sections...',
79
- store:Ext.create("Ext.data.Store",{
80
- proxy:{
81
- type:'ajax',
82
- url:'/knitkit/erp_app/desktop/section/existing_sections',
83
- reader:{
84
- type:'json'
85
- },
86
- extraParams:{
87
- website_id:record.data.websiteId
88
- }
89
- },
90
- autoLoad:true,
91
- fields:[
92
- {
93
- name:'id'
94
- },
95
- {
96
- name:'title_permalink'
97
-
98
- }
99
- ],
100
- listeners:{
101
- 'load':function(store, records, options){
102
- Ext.getCmp('knitkit_website_nav_item_section').setValue(record.data.linkedToId);
103
- }
104
- }
105
- }),
106
- forceSelection:true,
107
- editable:false,
108
- fieldLabel:'Section',
109
- autoSelect:true,
110
- typeAhead: false,
111
- queryMode: 'local',
112
- displayField:'title_permalink',
113
- valueField:'id',
114
- hidden:(record.data.linkToType != 'website_section' && record.data.linkToType != 'article')
115
- },
116
- {
117
- xtype:'textfield',
118
- fieldLabel:'Url',
119
- value:record.data.url,
120
- id:'knitkit_website_nav_item_url',
121
- hidden:(record.data.linkToType == 'website_section' || record.data.linkToType == 'article'),
122
- name:'url'
123
- },
124
- {
125
- xtype:'hidden',
126
- name:'website_nav_item_id',
127
- value:record.data.websiteNavItemId
128
- }
129
- ]
130
- }),
131
- buttons: [{
132
- text:'Submit',
133
- listeners:{
134
- 'click':function(button){
135
- var window = button.findParentByType('window'),
136
- formPanel = window.query('form')[0];
137
- self.setWindowStatus('Updating menu item...');
138
- formPanel.getForm().submit({
139
- reset:false,
140
- success:function(form, action){
141
- self.clearWindowStatus();
142
- var obj = Ext.decode(action.response.responseText);
143
- if(obj.success){
144
- record.data.linkedToId = obj.linkedToId;
145
- record.data.linkToType = obj.linkToType;
146
- record.data.url = obj.url;
147
- window.close();
148
- }
149
- else{
150
- Ext.Msg.alert("Error", obj.msg);
151
- }
152
- },
153
- failure:function(form, action){
154
- self.clearWindowStatus();
155
- if(action.response === null){
156
- Ext.Msg.alert("Error", 'Could not create menu item');
157
- }
158
- else{
159
- var obj = Ext.decode(action.response.responseText);
160
- Ext.Msg.alert("Error", obj.msg);
161
- }
162
-
163
- }
164
- });
165
- }
166
- }
167
- },{
168
- text: 'Close',
169
- handler: function(){
170
- addMenuItemWindow.close();
171
- }
172
- }]
173
- });
174
- addMenuItemWindow.show();
175
- }
176
- });
177
- }
178
-
179
- if (currentUser.hasCapability('unsecure','WebsiteNavItem') || currentUser.hasCapability('secure','WebsiteNavItem'))
180
- {
181
- items.push({
182
- text:'Security',
183
- iconCls:'icon-document_lock',
184
- listeners:{
185
- 'click':function(){
186
- self.changeSecurity(record, '/knitkit/erp_app/desktop/website_nav/update_security', record.data.websiteNavItemId);
187
- }
188
- }
189
- });
190
- }
191
-
192
- if (currentUser.hasCapability('delete','WebsiteNavItem'))
193
- {
194
- items.push({
195
- text:'Delete',
196
- iconCls:'icon-delete',
197
- handler:function(btn){
198
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu item?', function(btn){
199
- if(btn == 'no'){
200
- return false;
201
- }
202
- else
203
- if(btn == 'yes')
204
- {
205
- self.setWindowStatus('Deleting menu item...');
206
- Ext.Ajax.request({
207
- url: '/knitkit/erp_app/desktop/website_nav/delete_menu_item',
208
- method: 'POST',
209
- params:{
210
- id:record.data.websiteNavItemId
211
- },
212
- success: function(response) {
213
- self.clearWindowStatus();
214
- var obj = Ext.decode(response.responseText);
215
- if(obj.success){
216
- record.remove(true);
217
- }
218
- else{
219
- Ext.Msg.alert('Error', 'Error deleting menu item');
220
- }
221
- },
222
- failure: function(response) {
223
- self.clearWindowStatus();
224
- Ext.Msg.alert('Error', 'Error deleting menu item');
225
- }
226
- });
227
- }
228
- });
229
- }
230
- });
231
- }
232
-
233
- return items;
2
+ if (currentUser.hasCapability('edit', 'WebsiteNavItem')) {
3
+ items.push({
4
+ text: 'Update Menu Item',
5
+ iconCls: 'icon-edit',
6
+ handler: function (btn) {
7
+ var addMenuItemWindow = Ext.create("Ext.window.Window", {
8
+ layout: 'fit',
9
+ width: 375,
10
+ title: 'Update Menu Item',
11
+ height: 175,
12
+ plain: true,
13
+ buttonAlign: 'center',
14
+ items: Ext.create('Ext.form.Panel', {
15
+ labelWidth: 50,
16
+ frame: false,
17
+ bodyStyle: 'padding:5px 5px 0',
18
+ url: '/knitkit/erp_app/desktop/website_nav/update_menu_item',
19
+ defaults: {
20
+ width: 225
21
+ },
22
+ items: [
23
+ {
24
+ xtype: 'textfield',
25
+ fieldLabel: 'Title',
26
+ value: record.data.text,
27
+ allowBlank: false,
28
+ name: 'title'
29
+ },
30
+ {
31
+ xtype: 'combo',
32
+ fieldLabel: 'Link to',
33
+ name: 'link_to',
34
+ id: 'knitkit_nav_item_link_to',
35
+ allowBlank: false,
36
+ forceSelection: true,
37
+ editable: false,
38
+ autoSelect: true,
39
+ typeAhead: false,
40
+ mode: 'local',
41
+ triggerAction: 'all',
42
+ store: [
43
+ ['website_section', 'Section'],
44
+ //['article','Article'],
45
+ ['url', 'Url']
46
+
47
+ ],
48
+ value: record.data.linkToType,
49
+ listeners: {
50
+ 'change': function (combo, newValue, oldValue) {
51
+ switch (newValue) {
52
+ case 'website_section':
53
+ Ext.getCmp('knitkit_website_nav_item_section').show();
54
+ //Ext.getCmp('knitkit_website_nav_item_article').hide();
55
+ Ext.getCmp('knitkit_website_nav_item_url').hide();
56
+ break;
57
+ case 'article':
58
+ Ext.getCmp('knitkit_website_nav_item_section').hide();
59
+ //Ext.getCmp('knitkit_website_nav_item_article').show();
60
+ Ext.getCmp('knitkit_website_nav_item_url').hide();
61
+ break;
62
+ case 'url':
63
+ Ext.getCmp('knitkit_website_nav_item_section').hide();
64
+ //Ext.getCmp('knitkit_website_nav_item_article').hide();
65
+ Ext.getCmp('knitkit_website_nav_item_url').show();
66
+ break;
67
+ }
68
+ }
69
+ }
70
+ },
71
+ {
72
+ xtype: 'combo',
73
+ width: 300,
74
+ itemId: 'knitkit_website_nav_item_section',
75
+ hiddenName: 'website_section_id',
76
+ name: 'website_section_id',
77
+ loadingText: 'Retrieving Sections...',
78
+ store: Ext.create("Ext.data.Store", {
79
+ proxy: {
80
+ type: 'ajax',
81
+ url: '/knitkit/erp_app/desktop/section/existing_sections',
82
+ reader: {
83
+ type: 'json'
84
+ },
85
+ extraParams: {
86
+ website_id: record.data.websiteId
87
+ }
88
+ },
89
+ fields: [
90
+ {
91
+ name: 'id',
92
+ type: 'integer'
93
+ },
94
+ {
95
+ name: 'title_permalink',
96
+ type: 'string'
97
+ }
98
+ ]
99
+ }),
100
+ //forceSelection: true,
101
+ editable: false,
102
+ fieldLabel: 'Section',
103
+ //autoSelect: true,
104
+ typeAhead: false,
105
+ queryMode: 'local',
106
+ displayField: 'title_permalink',
107
+ valueField: 'id',
108
+ hidden: (record.data.linkToType != 'website_section' && record.data.linkToType != 'article')
109
+ },
110
+ {
111
+ xtype: 'textfield',
112
+ fieldLabel: 'Url',
113
+ value: record.data.url,
114
+ id: 'knitkit_website_nav_item_url',
115
+ hidden: (record.data.linkToType == 'website_section' || record.data.linkToType == 'article'),
116
+ name: 'url'
117
+ },
118
+ {
119
+ xtype: 'hidden',
120
+ name: 'website_nav_item_id',
121
+ value: record.data.websiteNavItemId
122
+ }
123
+ ]
124
+ }),
125
+ buttons: [
126
+ {
127
+ text: 'Submit',
128
+ listeners: {
129
+ 'click': function (button) {
130
+ var window = button.findParentByType('window'),
131
+ formPanel = window.query('form')[0];
132
+ self.setWindowStatus('Updating menu item...');
133
+ formPanel.getForm().submit({
134
+ reset: false,
135
+ success: function (form, action) {
136
+ self.clearWindowStatus();
137
+ var obj = Ext.decode(action.response.responseText);
138
+ if (obj.success) {
139
+ record.set('linkedToId', parseInt(obj.linkedToId));
140
+ record.set('linkToType', obj.linkToType);
141
+ record.set('url', obj.url);
142
+ record.set('text', obj.title);
143
+ record.commit();
144
+ window.close();
145
+ }
146
+ else {
147
+ Ext.Msg.alert("Error", obj.msg);
148
+ }
149
+ },
150
+ failure: function (form, action) {
151
+ self.clearWindowStatus();
152
+ if (action.response === null) {
153
+ Ext.Msg.alert("Error", 'Could not create menu item');
154
+ }
155
+ else {
156
+ var obj = Ext.decode(action.response.responseText);
157
+ Ext.Msg.alert("Error", obj.msg);
158
+ }
159
+ }
160
+ });
161
+ }
162
+ }
163
+ },
164
+ {
165
+ text: 'Close',
166
+ handler: function () {
167
+ addMenuItemWindow.close();
168
+ }
169
+ }
170
+ ],
171
+ listeners: {
172
+ show: function () {
173
+ var select = this.down('#knitkit_website_nav_item_section');
174
+ select.getStore().load({
175
+ callback: function () {
176
+ select.setValue(record.get('linkedToId'));
177
+ }
178
+ });
179
+ }
180
+ }
181
+ }).show();
182
+ }
183
+ });
184
+ }
185
+
186
+ if (currentUser.hasCapability('unsecure', 'WebsiteNavItem') || currentUser.hasCapability('secure', 'WebsiteNavItem')) {
187
+ items.push({
188
+ text: 'Security',
189
+ iconCls: 'icon-document_lock',
190
+ listeners: {
191
+ 'click': function () {
192
+ self.changeSecurity(record, '/knitkit/erp_app/desktop/website_nav/update_security', record.data.websiteNavItemId);
193
+ }
194
+ }
195
+ });
196
+ }
197
+
198
+ if (currentUser.hasCapability('delete', 'WebsiteNavItem')) {
199
+ items.push({
200
+ text: 'Delete',
201
+ iconCls: 'icon-delete',
202
+ handler: function (btn) {
203
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu item?', function (btn) {
204
+ if (btn == 'no') {
205
+ return false;
206
+ }
207
+ else if (btn == 'yes') {
208
+ self.setWindowStatus('Deleting menu item...');
209
+ Ext.Ajax.request({
210
+ url: '/knitkit/erp_app/desktop/website_nav/delete_menu_item',
211
+ method: 'POST',
212
+ params: {
213
+ id: record.data.websiteNavItemId
214
+ },
215
+ success: function (response) {
216
+ self.clearWindowStatus();
217
+ var obj = Ext.decode(response.responseText);
218
+ if (obj.success) {
219
+ record.remove(true);
220
+ }
221
+ else {
222
+ Ext.Msg.alert('Error', 'Error deleting menu item');
223
+ }
224
+ },
225
+ failure: function (response) {
226
+ self.clearWindowStatus();
227
+ Ext.Msg.alert('Error', 'Error deleting menu item');
228
+ }
229
+ });
230
+ }
231
+ });
232
+ }
233
+ });
234
+ }
235
+
236
+ return items;
234
237
  };
@@ -12,7 +12,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion", {
12
12
 
13
13
  deleteSection:function (node) {
14
14
  var self = this;
15
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this section?<br> NOTE: Articles belonging to this section will be orphaned.', function (btn) {
15
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this section?<br> NOTE: Articles belonging to this section will be orphaned.<br><br>', function (btn) {
16
16
  if (btn == 'no') {
17
17
  return false;
18
18
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knitkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.12
4
+ version: 2.1.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-01 00:00:00.000000000 Z
12
+ date: 2013-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erp_forms