knitkit 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/README.md +22 -0
  2. data/app/controllers/knitkit/base_controller.rb +15 -2
  3. data/app/controllers/knitkit/blogs_controller.rb +4 -4
  4. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +16 -2
  5. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +198 -57
  6. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +25 -11
  7. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +123 -44
  8. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +83 -9
  9. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +38 -0
  10. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +15 -6
  11. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +185 -98
  12. data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +38 -16
  13. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +126 -68
  14. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +154 -107
  15. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +113 -54
  16. data/app/controllers/knitkit/online_document_sections_controller.rb +45 -0
  17. data/app/controllers/knitkit/unauthorized_controller.rb +5 -0
  18. data/app/controllers/knitkit/website_sections_controller.rb +8 -9
  19. data/app/mailers/document_mailer.rb +10 -0
  20. data/app/models/article.rb +1 -1
  21. data/app/models/content.rb +35 -3
  22. data/app/models/document.rb +8 -0
  23. data/app/models/document_type.rb +3 -0
  24. data/app/models/documented_content.rb +29 -0
  25. data/app/models/documented_item.rb +31 -0
  26. data/app/models/extensions/configuration.rb +5 -0
  27. data/app/models/extensions/party.rb +13 -0
  28. data/app/models/online_document_section.rb +40 -0
  29. data/app/models/theme.rb +22 -26
  30. data/app/models/valid_document.rb +4 -0
  31. data/app/models/website.rb +158 -119
  32. data/app/models/website_inquiry.rb +7 -2
  33. data/app/models/website_inquiry_mailer.rb +4 -3
  34. data/app/models/website_party_role.rb +5 -0
  35. data/app/models/website_section.rb +76 -38
  36. data/app/views/document_mailer/email_document.html.erb +12 -0
  37. data/app/views/knitkit/blogs/_add_comment.html.erb +2 -2
  38. data/app/views/knitkit/online_document_sections/index.html.erb +149 -0
  39. data/app/views/knitkit/website_sections/index.html.erb +0 -1
  40. data/app/views/layouts/knitkit/base.html.erb +4 -2
  41. data/app/views/layouts/knitkit/online_document_sections.html.erb +59 -0
  42. data/app/views/menus/knitkit/_default_menu.html.erb +1 -1
  43. data/app/views/menus/knitkit/_default_section_menu.html.erb +1 -1
  44. data/app/views/menus/knitkit/_default_sub_menu.html.erb +2 -2
  45. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +1 -1
  46. data/app/widgets/contact_us/base.rb +5 -5
  47. data/app/widgets/contact_us/javascript/contact_us.js +2 -1
  48. data/app/widgets/google_map/base.rb +0 -4
  49. data/app/widgets/google_map/javascript/google_map.js +4 -3
  50. data/app/widgets/login/base.rb +0 -5
  51. data/app/widgets/login/javascript/login.js +155 -153
  52. data/app/widgets/login/views/index.html.erb +3 -3
  53. data/app/widgets/login/views/reset_password.html.erb +2 -2
  54. data/app/widgets/manage_profile/base.rb +46 -67
  55. data/app/widgets/manage_profile/javascript/manage_profile.js +2 -1
  56. data/app/widgets/manage_profile/views/_user_information_form.html.erb +5 -1
  57. data/app/widgets/reset_password/base.rb +4 -6
  58. data/app/widgets/reset_password/javascript/reset_password.js +2 -1
  59. data/app/widgets/reset_password/views/index.html.erb +4 -3
  60. data/app/widgets/search/base.rb +1 -5
  61. data/app/widgets/search/javascript/search.js +2 -1
  62. data/app/widgets/search/views/show.html.erb +2 -2
  63. data/app/widgets/signup/base.rb +7 -6
  64. data/app/widgets/signup/javascript/signup.js +2 -1
  65. data/app/widgets/signup/views/error.html.erb +1 -1
  66. data/config/routes.rb +6 -2
  67. data/db/data_migrations/20110509223702_add_publisher_role.rb +10 -0
  68. data/db/data_migrations/20111118182910_setup_knitkit_capabilities.rb +84 -0
  69. data/db/data_migrations/20120127144444_create_website_role_types.rb +13 -0
  70. data/db/data_migrations/20120127150505_create_website_default_configuration.rb +72 -0
  71. data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +33 -0
  72. data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +16 -0
  73. data/db/data_migrations/upgrade/20120210195616_add_website_configs.rb +19 -0
  74. data/db/data_migrations/upgrade/20120213205519_populate_website_iids.rb +17 -0
  75. data/db/migrate/20110211002317_setup_knitkit.rb +22 -5
  76. data/db/migrate/20111207161928_create_documented_items_table.rb +13 -0
  77. data/db/migrate/20111208180539_add_document_id_to_documented_item.rb +9 -0
  78. data/db/migrate/20120315163736_add_document.rb +32 -0
  79. data/db/migrate/20120503183431_create_valid_documents.rb +16 -0
  80. data/db/migrate/upgrade/20120116201510_add_render_base_layout_flag.rb +13 -0
  81. data/db/migrate/upgrade/20120127143745_create_website_party_roles.rb +24 -0
  82. data/db/migrate/upgrade/20120213184509_add_iid_to_websites.rb +14 -0
  83. data/lib/knitkit.rb +2 -0
  84. data/lib/knitkit/config.rb +31 -0
  85. data/lib/knitkit/engine.rb +12 -3
  86. data/lib/knitkit/extensions.rb +1 -3
  87. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +2 -3
  88. data/lib/knitkit/extensions/active_record/acts_as_document.rb +63 -0
  89. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +5 -4
  90. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +70 -0
  91. data/lib/knitkit/extensions/railties/action_view.rb +22 -10
  92. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +3 -3
  93. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +8 -3
  94. data/lib/knitkit/routing_filter/section_router.rb +16 -6
  95. data/lib/knitkit/version.rb +7 -1
  96. data/public/images/check.png +0 -0
  97. data/public/images/credit_card.png +0 -0
  98. data/public/images/knitkit/tooltip.gif +0 -0
  99. data/public/javascripts/ajax_pagination.js +33 -0
  100. data/public/javascripts/datepicker.js +6 -1
  101. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +731 -258
  102. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +289 -238
  103. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +2 -4
  104. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +29 -3
  105. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +193 -21
  106. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +27 -26
  107. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +167 -20
  108. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +1 -2
  109. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +5 -1
  110. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +2 -2
  111. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +20 -11
  112. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +279 -228
  113. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +40 -40
  114. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +83 -76
  115. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +1961 -1397
  116. data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +47 -43
  117. data/public/javascripts/knitkit/helpers.js +26 -0
  118. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +1 -2
  119. data/public/stylesheets/knitkit/documentation.css +50 -0
  120. data/public/stylesheets/knitkit/style.css +23 -1
  121. data/spec/controllers/knitkit/erp_app/desktop/articles_controller_spec.rb +8 -0
  122. data/spec/controllers/knitkit/erp_app/desktop/website_controller_spec.rb +396 -0
  123. data/spec/controllers/knitkit/erp_app/desktop/website_nav_controller_spec.rb +260 -0
  124. data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +222 -0
  125. data/spec/dummy/Rakefile +7 -0
  126. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  127. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  128. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  129. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  130. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  131. data/spec/dummy/config.ru +4 -0
  132. data/spec/dummy/config/application.rb +43 -0
  133. data/spec/dummy/config/boot.rb +10 -0
  134. data/spec/dummy/config/database.yml +8 -0
  135. data/spec/dummy/config/environment.rb +5 -0
  136. data/spec/dummy/config/environments/spec.rb +27 -0
  137. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  138. data/spec/dummy/config/initializers/inflections.rb +10 -0
  139. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  140. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  141. data/spec/dummy/config/initializers/session_store.rb +8 -0
  142. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  143. data/spec/dummy/config/locales/en.yml +5 -0
  144. data/spec/dummy/config/routes.rb +4 -0
  145. data/spec/dummy/config/workflow.yml +1 -0
  146. data/spec/dummy/public/404.html +26 -0
  147. data/spec/dummy/public/422.html +26 -0
  148. data/spec/dummy/public/500.html +26 -0
  149. data/spec/dummy/public/favicon.ico +0 -0
  150. data/spec/dummy/script/rails +6 -0
  151. data/spec/factories/article.rb +4 -0
  152. data/spec/factories/basic.rb +3 -0
  153. data/spec/factories/blog.rb +5 -0
  154. data/spec/factories/documented_content.rb +4 -0
  155. data/spec/factories/documented_item.rb +4 -0
  156. data/spec/factories/online_document_section.rb +6 -0
  157. data/spec/factories/published_website.rb +4 -0
  158. data/spec/factories/theme.rb +6 -0
  159. data/spec/factories/website.rb +5 -0
  160. data/spec/factories/website_host.rb +4 -0
  161. data/spec/factories/website_nav.rb +5 -0
  162. data/spec/factories/website_nav_item.rb +4 -0
  163. data/spec/factories/website_section.rb +5 -0
  164. data/spec/models/article_spec.rb +35 -0
  165. data/spec/models/attribute_type_spec.rb +55 -0
  166. data/spec/models/attribute_value_spec.rb +114 -0
  167. data/spec/models/blog_spec.rb +16 -0
  168. data/spec/models/comment_spec.rb +11 -0
  169. data/spec/models/content_spec.rb +187 -0
  170. data/spec/models/documented_item_spec.rb +29 -0
  171. data/spec/models/online_document_section_spec.rb +34 -0
  172. data/spec/models/published_element_spec.rb +11 -0
  173. data/spec/models/published_website_spec.rb +11 -0
  174. data/spec/models/theme_spec.rb +12 -0
  175. data/spec/models/website_host_spec.rb +11 -0
  176. data/spec/models/website_inquiry_spec.rb +24 -0
  177. data/spec/models/website_nav_item_spec.rb +11 -0
  178. data/spec/models/website_nav_spec.rb +11 -0
  179. data/spec/models/website_section_content_spec.rb +11 -0
  180. data/spec/models/website_section_spec.rb +49 -0
  181. data/spec/models/website_spec.rb +146 -0
  182. data/spec/spec_helper.rb +61 -0
  183. metadata +391 -154
  184. data/app/controllers/knitkit/articles_controller.rb +0 -7
  185. data/lib/knitkit/extensions/compass/widgets/base.rb +0 -53
@@ -4,7 +4,7 @@
4
4
  selected_menu_item = nil
5
5
  menu_items.each do |menu_item|
6
6
  %>
7
- <%if menu_item.has_access?(current_user)%>
7
+ <%if menu_item.has_access?(@current_user)%>
8
8
  <% if menu_item_selected(menu_item)
9
9
  selected_menu_item = menu_item
10
10
  %>
@@ -6,7 +6,7 @@
6
6
  <ul id="menu">
7
7
  <% @website_sections.each do |section| %>
8
8
  <%if section.in_menu %>
9
- <%if section.has_access?(current_user)%>
9
+ <%if section.has_access?(@current_user)%>
10
10
  <% if (!@website_section.nil? && section.id == @website_section.id) or (!selected_section_parent.nil? and selected_section_parent.id == section.id) %>
11
11
  <li class="selected">
12
12
  <%
@@ -3,7 +3,7 @@
3
3
  <ul id="side_menu">
4
4
  <%
5
5
  menu_items.each do |menu_item| %>
6
- <%if menu_item.has_access?(current_user)%>
6
+ <%if menu_item.has_access?(@current_user)%>
7
7
  <% if menu_item_selected(menu_item) %>
8
8
  <li class="selected">
9
9
  <%
@@ -19,7 +19,7 @@
19
19
  <% unless selected_menu_item.positioned_children.nil? %>
20
20
  <ul class="side_menu_children">
21
21
  <% selected_menu_item.positioned_children.each do |child_menu_item| %>
22
- <% if child_menu_item.has_access?(current_user)%>
22
+ <% if child_menu_item.has_access?(@current_user)%>
23
23
  <% if menu_item_selected(child_menu_item) %>
24
24
  <li class="selected">
25
25
  <% else %>
@@ -7,7 +7,7 @@
7
7
  <ul id="side_menu">
8
8
  <% section.positioned_children.each do |child_section| %>
9
9
  <%if child_section.in_menu %>
10
- <%if child_section.has_access?(current_user)%>
10
+ <%if child_section.has_access?(@current_user)%>
11
11
  <% if (!@website_section.nil? && child_section.id == @website_section.id) or (!selected_section_parent.nil? and selected_section_parent.id == child_section.id) %>
12
12
  <li class="selected">
13
13
  <%
@@ -1,6 +1,8 @@
1
1
  module Widgets
2
2
  module ContactUs
3
3
  class Base < ErpApp::Widgets::Base
4
+ include ActionView::Helpers::SanitizeHelper
5
+
4
6
  def index
5
7
  @use_dynamic_form = params[:use_dynamic_form]
6
8
 
@@ -22,6 +24,8 @@ module Widgets
22
24
  @website = Website.find_by_host(request.host_with_port)
23
25
  @website_inquiry = WebsiteInquiry.new
24
26
 
27
+ subject = strip_tags(params[:email_subject])
28
+ params.delete(:email_subject)
25
29
  params[:created_by] = current_user unless current_user.nil?
26
30
  params[:created_with_form_id] = params[:dynamic_form_id] if params[:dynamic_form_id] and params[:is_html_form].blank?
27
31
  params[:website_id] = @website.id
@@ -29,7 +33,7 @@ module Widgets
29
33
 
30
34
  if @website_inquiry
31
35
  if @website.email_inquiries?
32
- @website_inquiry.send_email
36
+ @website_inquiry.send_email(subject)
33
37
  end
34
38
 
35
39
  if @is_html_form
@@ -62,10 +66,6 @@ module Widgets
62
66
  def title
63
67
  "Contact Us"
64
68
  end
65
-
66
- def views_location
67
- File.join(File.dirname(__FILE__),"/views")
68
- end
69
69
 
70
70
  def widget_name
71
71
  File.basename(File.dirname(__FILE__))
@@ -7,7 +7,8 @@ Compass.ErpApp.Widgets.ContactUs = {
7
7
  Compass.ErpApp.Widgets.AvailableWidgets.push({
8
8
  name:'Contact Us',
9
9
  iconUrl:'/images/icons/message/message_48x48.png',
10
- onClick:Compass.ErpApp.Widgets.ContactUs.addContactUs
10
+ onClick:Compass.ErpApp.Widgets.ContactUs.addContactUs,
11
+ about:'This widget creates a form to allow for website inqueries.'
11
12
  });
12
13
 
13
14
 
@@ -27,10 +27,6 @@ module Widgets
27
27
  def widget_name
28
28
  File.basename(File.dirname(__FILE__))
29
29
  end
30
-
31
- def views_location
32
- File.join(File.dirname(__FILE__),"/views")
33
- end
34
30
 
35
31
  def base_layout
36
32
  begin
@@ -16,8 +16,8 @@ Compass.ErpApp.Widgets.GoogleMap = {
16
16
  type: 'memory'
17
17
  },
18
18
  data:[{
19
- title:'Google Inc.',
20
- address:'1600 Amphitheatre Parkway Mountain View, CA 94043'
19
+ title:'TrueNorth.',
20
+ address:'1 S Orange Ave Orlando, FL 32801'
21
21
  }]
22
22
  });
23
23
 
@@ -170,5 +170,6 @@ Compass.ErpApp.Widgets.GoogleMap = {
170
170
  Compass.ErpApp.Widgets.AvailableWidgets.push({
171
171
  name:'Google Map',
172
172
  iconUrl:'/images/icons/map/map_48x48.png',
173
- onClick:Compass.ErpApp.Widgets.GoogleMap.addGoogleMap
173
+ onClick:Compass.ErpApp.Widgets.GoogleMap.addGoogleMap,
174
+ about:'This widget creates a google map with drop points you setup.'
174
175
  });
@@ -1,4 +1,3 @@
1
-
2
1
  module Widgets
3
2
  module Login
4
3
  class Base < ErpApp::Widgets::Base
@@ -42,10 +41,6 @@ module Widgets
42
41
  File.join(File.dirname(__FILE__),"/views")
43
42
  end
44
43
 
45
- def widget_name
46
- File.basename(File.dirname(__FILE__))
47
- end
48
-
49
44
  def base_layout
50
45
  begin
51
46
  file = File.join(File.dirname(__FILE__),"/views/layouts/base.html.erb")
@@ -1,162 +1,164 @@
1
1
  Compass.ErpApp.Widgets.Login = {
2
- addLogin:function(){
3
- var addLoginWidgetWindow = Ext.create("Ext.window.Window",{
4
- layout:'fit',
5
- width:375,
6
- title:'Add Login Widget',
7
- plain: true,
8
- buttonAlign:'center',
9
- items: Ext.create("Ext.form.Panel",{
10
- labelWidth: 100,
11
- frame:false,
12
- bodyStyle:'padding:5px 5px 0',
13
- defaults: {
14
- width: 225
15
- },
16
- items: [
17
- {
18
- width: 150,
19
- xtype: 'combo',
20
- forceSelection:true,
21
- store: [
22
- [':login_header','Header'],
23
- [':login_page','Page'],
24
- ],
25
- fieldLabel: 'Widget View',
26
- value:':login_page',
27
- name: 'widgetLayout',
28
- allowBlank: false,
29
- triggerAction: 'all',
30
- listeners:{
31
- change:function(field, newValue, oldValue){
32
- var basicForm = field.findParentByType('form').getForm();
33
- var loginWidgetLoginToField = basicForm.findField('loginWidgetLoginTo');
34
- var loginWidgetLogoutToField = basicForm.findField('loginWidgetLogoutTo');
35
- var loginWidgetLoginUrlField = basicForm.findField('loginWidgetLoginUrl');
36
- var loginWidgetSignUpUrlField = basicForm.findField('loginWidgetSignUpUrl');
37
- var loginWidgetResetPasswordUrlField = basicForm.findField('loginWidgetResetPasswordUrl');
38
- if(newValue == ':login_header'){
39
- loginWidgetLoginToField.hide();
40
- loginWidgetLogoutToField.hide();
41
- loginWidgetLoginUrlField.show();
42
- loginWidgetResetPasswordUrlField.hide();
43
- loginWidgetLoginUrlField.setValue('/login');
44
- loginWidgetSignUpUrlField.setValue('/sign-up');
45
- loginWidgetResetPasswordUrlField.setValue('/reset-password');
46
- }
47
- else{
48
- loginWidgetLoginToField.show();
49
- loginWidgetLogoutToField.show();
50
- loginWidgetLoginUrlField.hide();
51
- loginWidgetResetPasswordUrlField.show();
52
- loginWidgetLoginToField.setValue('/home');
53
- loginWidgetLogoutToField.setValue('/home');
54
- loginWidgetSignUpUrlField.setValue('/sign-up');
55
- }
56
- }
57
- }
58
- },
59
- {
60
- xtype:'textfield',
61
- fieldLabel:'Login To',
62
- allowBlank:false,
63
- value:'/home',
64
- id:'loginWidgetLoginTo'
65
- },
66
- {
67
- xtype:'textfield',
68
- fieldLabel:'Logout To',
69
- allowBlank:false,
70
- value:'/home',
71
- id:'loginWidgetLogoutTo'
72
- },
73
- {
74
- xtype:'textfield',
75
- fieldLabel:'Login Url',
76
- allowBlank:false,
77
- hidden:true,
78
- value:'/login',
79
- id:'loginWidgetLoginUrl'
80
- },
81
- {
82
- xtype:'textfield',
83
- toolTip:'Only needed if Signup widget is setup.',
84
- fieldLabel:'Sign Up Url',
85
- allowBlank:true,
86
- value:'/sign-up',
87
- id:'loginWidgetSignUpUrl'
88
- },
89
- {
90
- xtype:'textfield',
91
- toolTip:'Only needed if Reset Password widget is setup.',
92
- fieldLabel:'Reset Password Url',
93
- allowBlank:true,
94
- hidden:true,
95
- value:'/reset-password',
96
- id:'loginWidgetResetPasswordUrl'
97
- }
98
- ]
99
- }),
100
- buttons: [{
101
- text:'Submit',
102
- listeners:{
103
- 'click':function(button){
104
- var tpl = null;
105
- var content = null;
106
- var window = button.findParentByType('window');
107
- var formPanel = window.query('form')[0];
108
- var basicForm = formPanel.getForm();
109
- var action = basicForm.findField('widgetLayout').getValue();
2
+ addLogin:function(){
3
+ var addLoginWidgetWindow = Ext.create("Ext.window.Window",{
4
+ layout:'fit',
5
+ width:375,
6
+ title:'Add Login Widget',
7
+ plain: true,
8
+ buttonAlign:'center',
9
+ items: Ext.create("Ext.form.Panel",{
10
+ labelWidth: 100,
11
+ frame:false,
12
+ bodyStyle:'padding:5px 5px 0',
13
+ defaults: {
14
+ width: 225
15
+ },
16
+ items: [
17
+ {
18
+ xtype: 'combo',
19
+ forceSelection:true,
20
+ store: [
21
+ [':login_header','Header'],
22
+ [':login_page','Page'],
23
+ ],
24
+ fieldLabel: 'Widget View',
25
+ value:':login_page',
26
+ name: 'widgetLayout',
27
+ allowBlank: false,
28
+ triggerAction: 'all',
29
+ listeners:{
30
+ change:function(field, newValue, oldValue){
31
+ var basicForm = field.findParentByType('form').getForm();
32
+ var loginWidgetLoginToField = basicForm.findField('loginWidgetLoginTo');
33
+ var loginWidgetLogoutToField = basicForm.findField('loginWidgetLogoutTo');
34
+ var loginWidgetLoginUrlField = basicForm.findField('loginWidgetLoginUrl');
35
+ var loginWidgetSignUpUrlField = basicForm.findField('loginWidgetSignUpUrl');
36
+ var loginWidgetResetPasswordUrlField = basicForm.findField('loginWidgetResetPasswordUrl');
37
+ if(newValue == ':login_header'){
38
+ loginWidgetLoginToField.hide();
39
+ loginWidgetLogoutToField.hide();
40
+ loginWidgetLoginUrlField.show();
41
+ loginWidgetResetPasswordUrlField.hide();
42
+ loginWidgetLoginUrlField.setValue('/login');
43
+ loginWidgetSignUpUrlField.setValue('/sign-up');
44
+ loginWidgetResetPasswordUrlField.setValue('/reset-password');
45
+ }
46
+ else{
47
+ loginWidgetLoginToField.show();
48
+ loginWidgetLogoutToField.show();
49
+ loginWidgetLoginUrlField.hide();
50
+ loginWidgetResetPasswordUrlField.show();
51
+ loginWidgetLoginToField.setValue('/home');
52
+ loginWidgetLogoutToField.setValue('/home');
53
+ loginWidgetSignUpUrlField.setValue('/sign-up');
54
+ }
55
+ }
56
+ }
57
+ },
58
+ {
59
+ xtype:'textfield',
60
+ fieldLabel:'Login To',
61
+ allowBlank:false,
62
+ value:'/home',
63
+ id:'loginWidgetLoginTo'
64
+ },
65
+ {
66
+ xtype:'textfield',
67
+ fieldLabel:'Logout To',
68
+ allowBlank:false,
69
+ value:'/home',
70
+ id:'loginWidgetLogoutTo'
71
+ },
72
+ {
73
+ xtype:'textfield',
74
+ fieldLabel:'Login Url',
75
+ allowBlank:false,
76
+ hidden:true,
77
+ value:'/login',
78
+ id:'loginWidgetLoginUrl'
79
+ },
80
+ {
81
+ xtype:'textfield',
82
+ toolTip:'Only needed if Signup widget is setup.',
83
+ fieldLabel:'Sign Up Url',
84
+ allowBlank:true,
85
+ value:'/sign-up',
86
+ id:'loginWidgetSignUpUrl'
87
+ },
88
+ {
89
+ xtype:'textfield',
90
+ toolTip:'Only needed if Reset Password widget is setup.',
91
+ fieldLabel:'Reset Password Url',
92
+ allowBlank:true,
93
+ hidden:true,
94
+ value:'/reset-password',
95
+ id:'loginWidgetResetPasswordUrl'
96
+ }
97
+ ]
98
+ }),
99
+ buttons: [{
100
+ text:'Submit',
101
+ listeners:{
102
+ 'click':function(button){
103
+ var tpl = null;
104
+ var content = null;
105
+ var window = button.findParentByType('window');
106
+ var formPanel = window.query('form')[0];
107
+ var basicForm = formPanel.getForm();
108
+ var action = basicForm.findField('widgetLayout').getValue();
110
109
 
111
- var loginWidgetSignUpUrlField = basicForm.findField('loginWidgetSignUpUrl');
112
- var loginWidgetResetPasswordUrlField = basicForm.findField('loginWidgetResetPasswordUrl');
113
- var data = {action:action};
114
- data.loginWidgetSignUpUrl = loginWidgetSignUpUrlField.getValue();
115
- data.loginWidgetResetPasswordUrl = loginWidgetResetPasswordUrlField.getValue();
116
- if(action == ':login_header'){
117
- var loginWidgetLoginUrlField = basicForm.findField('loginWidgetLoginUrl');
118
- data.loginWidgetLoginUrl = loginWidgetLoginUrlField.getValue();
119
- tpl = new Ext.XTemplate("<%= render_widget :login,\n",
120
- " :action => :login_header,\n",
121
- " :params => {:login_url => '{loginWidgetLoginUrl}',\n",
122
- " :signup_url => '{loginWidgetSignUpUrl}'}%>");
123
- content = tpl.apply(data);
124
- }
125
- else{
126
- var loginWidgetLoginToField = basicForm.findField('loginWidgetLoginTo');
127
- var loginWidgetLogoutToField = basicForm.findField('loginWidgetLogoutTo');
128
- data.loginWidgetLoginTo = loginWidgetLoginToField.getValue();
129
- data.loginWidgetLogoutTo = loginWidgetLogoutToField.getValue();
130
- tpl = new Ext.XTemplate("<%= render_widget :login,\n",
131
- " :params => {:login_to => '{loginWidgetLoginTo}',\n",
132
- " :logout_to => '{loginWidgetLogoutTo}',\n",
133
- " #optional field if Sign Up widget is setup\n",
134
- " #:signup_url => '{loginWidgetSignUpUrl}',\n",
135
- " #optional field if Reset Password widget is setup\n",
136
- " #:reset_password_url => '{loginWidgetResetPasswordUrl}'}%>");
137
- content = tpl.apply(data);
138
- }
110
+ var loginWidgetSignUpUrlField = basicForm.findField('loginWidgetSignUpUrl');
111
+ var loginWidgetResetPasswordUrlField = basicForm.findField('loginWidgetResetPasswordUrl');
112
+ var data = {
113
+ action:action
114
+ };
115
+ data.loginWidgetSignUpUrl = loginWidgetSignUpUrlField.getValue();
116
+ data.loginWidgetResetPasswordUrl = loginWidgetResetPasswordUrlField.getValue();
117
+ if(action == ':login_header'){
118
+ var loginWidgetLoginUrlField = basicForm.findField('loginWidgetLoginUrl');
119
+ data.loginWidgetLoginUrl = loginWidgetLoginUrlField.getValue();
120
+ tpl = new Ext.XTemplate("<%= render_widget :login,\n",
121
+ " :action => :login_header,\n",
122
+ " :params => {:login_url => '{loginWidgetLoginUrl}',\n",
123
+ " :signup_url => '{loginWidgetSignUpUrl}'}%>");
124
+ content = tpl.apply(data);
125
+ }
126
+ else{
127
+ var loginWidgetLoginToField = basicForm.findField('loginWidgetLoginTo');
128
+ var loginWidgetLogoutToField = basicForm.findField('loginWidgetLogoutTo');
129
+ data.loginWidgetLoginTo = loginWidgetLoginToField.getValue();
130
+ data.loginWidgetLogoutTo = loginWidgetLogoutToField.getValue();
131
+ tpl = new Ext.XTemplate("<%= render_widget :login,\n",
132
+ " :params => {:login_to => '{loginWidgetLoginTo}',\n",
133
+ " :logout_to => '{loginWidgetLogoutTo}',\n",
134
+ " #optional field if Sign Up widget is setup\n",
135
+ " #:signup_url => '{loginWidgetSignUpUrl}',\n",
136
+ " #optional field if Reset Password widget is setup\n",
137
+ " #:reset_password_url => '{loginWidgetResetPasswordUrl}'}%>");
138
+ content = tpl.apply(data);
139
+ }
139
140
 
140
- //add rendered template to center region editor
141
- Ext.getCmp('knitkitCenterRegion').addContentToActiveCodeMirror(content);
142
- addLoginWidgetWindow.close();
143
- }
144
- }
145
- },{
146
- text: 'Close',
147
- handler: function(){
148
- addLoginWidgetWindow.close();
149
- }
150
- }]
151
- });
152
- addLoginWidgetWindow.show();
153
- }
141
+ //add rendered template to center region editor
142
+ Ext.getCmp('knitkitCenterRegion').addContentToActiveCodeMirror(content);
143
+ addLoginWidgetWindow.close();
144
+ }
145
+ }
146
+ },{
147
+ text: 'Close',
148
+ handler: function(){
149
+ addLoginWidgetWindow.close();
150
+ }
151
+ }]
152
+ });
153
+ addLoginWidgetWindow.show();
154
+ }
154
155
  }
155
156
 
156
157
  Compass.ErpApp.Widgets.AvailableWidgets.push({
157
- name:'Login',
158
- iconUrl:'/images/icons/key/key_48x48.png',
159
- onClick:Compass.ErpApp.Widgets.Login.addLogin
158
+ name:'Login',
159
+ iconUrl:'/images/icons/key/key_48x48.png',
160
+ onClick:Compass.ErpApp.Widgets.Login.addLogin,
161
+ about:'This widget creates a login form to allow users to log into the website.'
160
162
  });
161
163
 
162
164