mcms_pages 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/app/assets/images/layouts/default.png +0 -0
  2. data/app/assets/javascripts/pageFormAdmin.js +50 -15
  3. data/app/assets/stylesheets/mcms_pages/images/back_ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  4. data/app/assets/stylesheets/mcms_pages/images/spellayt.gif +0 -0
  5. data/app/assets/stylesheets/mcms_pages/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  6. data/app/assets/stylesheets/mcms_pages/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  7. data/app/assets/stylesheets/mcms_pages/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  8. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  9. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  10. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  11. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  12. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  13. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  14. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  15. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  16. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  17. data/app/assets/stylesheets/mcms_pages/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  18. data/app/assets/stylesheets/mcms_pages/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  19. data/app/assets/stylesheets/mcms_pages/images/ui-bg_green.png +1 -0
  20. data/app/assets/stylesheets/mcms_pages/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  21. data/app/assets/stylesheets/mcms_pages/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  22. data/app/assets/stylesheets/mcms_pages/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  23. data/app/assets/stylesheets/mcms_pages/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  24. data/app/assets/stylesheets/mcms_pages/images/ui-icons_217bc0_256x240.png +0 -0
  25. data/app/assets/stylesheets/mcms_pages/images/ui-icons_222222_256x240.png +0 -0
  26. data/app/assets/stylesheets/mcms_pages/images/ui-icons_2e83ff_256x240.png +0 -0
  27. data/app/assets/stylesheets/mcms_pages/images/ui-icons_454545_256x240.png +0 -0
  28. data/app/assets/stylesheets/mcms_pages/images/ui-icons_469bdd_256x240.png +0 -0
  29. data/app/assets/stylesheets/mcms_pages/images/ui-icons_6da8d5_256x240.png +0 -0
  30. data/app/assets/stylesheets/mcms_pages/images/ui-icons_888888_256x240.png +0 -0
  31. data/app/assets/stylesheets/mcms_pages/images/ui-icons_cd0a0a_256x240.png +0 -0
  32. data/app/assets/stylesheets/mcms_pages/images/ui-icons_d8e7f3_256x240.png +0 -0
  33. data/app/assets/stylesheets/mcms_pages/images/ui-icons_f9bd01_256x240.png +0 -0
  34. data/app/assets/stylesheets/mcms_pages/layout.css.scss +5 -5
  35. data/app/assets/stylesheets/mcms_pages/page_form.css.scss +64 -0
  36. data/app/assets/stylesheets/mcms_pages/page_styles.css +92 -15
  37. data/app/assets/stylesheets/mcms_pages/pages.css.scss +37 -24
  38. data/app/assets/stylesheets/mcms_pages/tabs.css +573 -0
  39. data/app/controllers/admin/layouts_controller.rb +1 -1
  40. data/app/controllers/admin/pages_controller.rb +54 -28
  41. data/app/controllers/admin_controller.rb +36 -2
  42. data/app/controllers/pages_controller.rb +23 -11
  43. data/app/helpers/pages_helper.rb +52 -44
  44. data/app/models/ckeditor/asset.rb +2 -1
  45. data/app/models/page.rb +5 -1
  46. data/app/models/page_part.rb +25 -44
  47. data/app/views/mcms_pages/admin/layouts/index.html.erb +9 -6
  48. data/app/views/mcms_pages/admin/pages/_action.html.erb +22 -3
  49. data/app/views/mcms_pages/admin/pages/_form.html.erb +8 -8
  50. data/app/views/mcms_pages/admin/pages/_form.js.erb +12 -11
  51. data/app/views/mcms_pages/admin/pages/_page_part_edit_form.html.erb +18 -45
  52. data/app/views/mcms_pages/admin/pages/_page_part_edit_form.html.erb~ +113 -0
  53. data/app/views/mcms_pages/admin/pages/_page_part_form.html.erb +5 -5
  54. data/app/views/mcms_pages/admin/pages/_page_part_form.html.erb~ +133 -0
  55. data/app/views/mcms_pages/admin/pages/_page_part_form_field.html.erb +36 -6
  56. data/app/views/mcms_pages/admin/pages/_page_part_page_form_field.html.erb +9 -19
  57. data/app/views/mcms_pages/admin/pages/add_page_part.js.erb +26 -4
  58. data/app/views/mcms_pages/admin/pages/edit.html.erb +2 -0
  59. data/app/views/mcms_pages/admin/pages/index.html.erb +4 -2
  60. data/app/views/mcms_pages/admin/pages/new.html.erb +2 -0
  61. data/app/views/mcms_pages/layouts/_footer.html.erb +3 -2
  62. data/app/views/mcms_pages/layouts/_head.html.erb +18 -0
  63. data/app/views/mcms_pages/layouts/_header.html.erb +3 -2
  64. data/app/views/mcms_pages/layouts/_javascript.html.erb +1 -1
  65. data/app/views/mcms_pages/layouts/_stylesheets.html.erb +2 -3
  66. data/app/views/mcms_pages/layouts/mcms_layout.html.erb +2 -3
  67. data/app/views/mcms_pages/pages/_left_side_body.html.erb +1 -4
  68. data/app/views/mcms_pages/pages/_main_body.html.erb +8 -3
  69. data/app/views/mcms_pages/pages/_menu.html.erb +6 -2
  70. data/app/views/mcms_pages/pages/_menubar.html.erb +16 -6
  71. data/app/views/mcms_pages/pages/_one_column_layout.html.erb +5 -2
  72. data/app/views/mcms_pages/pages/_right_side_body.html.erb +1 -4
  73. data/app/views/mcms_pages/pages/_three_column_layout.html.erb +17 -6
  74. data/app/views/mcms_pages/pages/_two_column_layout.html.erb +21 -9
  75. data/app/views/mcms_pages/pages/home.html.erb +10 -8
  76. data/app/views/mcms_pages/pages/show.html.erb +14 -6
  77. data/db/migrate/20120718115449_add_depth_to_pages.rb +5 -0
  78. data/db/seeds.rb +5 -3
  79. data/lib/generators/mcms_pages/mcms_pages_generator.rb +1 -1
  80. data/lib/generators/mcms_pages/templates/{asset_manager.rb → asset.rb} +28 -25
  81. data/lib/mcms_pages/engine.rb +1 -0
  82. metadata +42 -6
  83. data/app/assets/javascripts/menuPage.js +0 -45
  84. data/app/controllers/application_controller.rb +0 -20
@@ -29,7 +29,7 @@
29
29
  </div>
30
30
  <div class="field">
31
31
 
32
- <%= f.label :title, "Title of the Page:" %><br />
32
+ <%= f.label :title, "Title of the Page:" %>
33
33
  <%= f.text_field :title, :title => "This will be the title of your page" %>
34
34
 
35
35
  </div>
@@ -52,28 +52,28 @@
52
52
  </div>
53
53
  <div class="field">
54
54
 
55
- <%= f.label :parent_id, "Parent Page(If Any)" %><br />
55
+ <%= f.label :parent_id, "Parent Page(If Any):" %>
56
56
 
57
- <!-- calling form helper method to render dropdown box -->
58
- <%= f.select(:parent_id, @pages.collect {|p| [ p.title, p.id ] }, {:include_blank => 'Select Page'}) %>
57
+ <!-- calling form helper method and awesome_nested_set helper method to render dropdown box -->
58
+ <%= f.select(:parent_id, nested_set_options(Page, @page) {|p| p.title }, {:include_blank => 'Select Page'}) %>
59
59
 
60
60
  </div>
61
61
  <div class="field">
62
62
 
63
- <%= f.label :link_url %><br />
64
- <%= f.text_field :link_url %>
63
+ <%= f.label :link_url, "Forward this page to another website or page: " %>
64
+ <%= f.text_field :link_url, :title => "Use full url, e.g.- http://www.google.com" %>
65
65
 
66
66
  </div>
67
67
  <div class="field">
68
68
 
69
- <%= f.label :show_in_menu %><br />
70
69
  <%= f.check_box :show_in_menu %>
70
+ <%= f.label :show_in_menu %>
71
71
 
72
72
  </div>
73
73
  <div class="field">
74
74
 
75
- <%= f.label :published %><br />
76
75
  <%= f.check_box :published %>
76
+ <%= f.label :published, "Publish this page" %>
77
77
 
78
78
  </div>
79
79
  <div class="actions">
@@ -4,14 +4,14 @@
4
4
  @Company Name : Mindfire Solutions Private Limited
5
5
  @Creator Name : Vikram Kumar Mishra
6
6
  @Date Created : 2012-06-19
7
- @Date Modified :
7
+ @Date Modified :
8
8
  @Last Modification Details :
9
9
  @Purpose : To show the page preview on click of preview submit button.
10
10
 
11
11
  -->
12
12
 
13
13
  <script type="text/javascript">
14
-
14
+
15
15
  $(document).ready(function(){
16
16
 
17
17
  // on click of preview button
@@ -28,10 +28,10 @@
28
28
 
29
29
  // setting the new action and target for form element
30
30
  formElt.attr({
31
-
31
+
32
32
  'action': '<%= @page.persisted? ? preview_page_path(@page.nested_url) : preview_pages_path %>',
33
33
  'target': '_blank'
34
-
34
+
35
35
  });
36
36
 
37
37
  //submit the form
@@ -39,17 +39,18 @@
39
39
 
40
40
  // reset the action for form element
41
41
  formElt.attr({
42
-
42
+
43
43
  'action': formAction,
44
- 'target': formTarget
45
-
44
+ 'target': ""
45
+
46
46
  });
47
47
 
48
48
  //prevent the defaault action for the click event
49
49
  e.preventDefault();
50
-
50
+
51
51
  });
52
-
52
+
53
53
  });
54
-
55
- </script>
54
+
55
+ </script>
56
+
@@ -10,9 +10,11 @@
10
10
 
11
11
  -->
12
12
 
13
- <div id='page-tabs' class="page-tabs">
13
+ <% page = arrange_page_part(@page) %>
14
14
 
15
- <ul id='page-parts-ul'>
15
+ <div id='page-tabs' class="page-tabs clearfix ui-tabs ui-widget ui-widget-content ui-corner-all" >
16
+
17
+ <ul id='page-parts-ul' class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" >
16
18
 
17
19
  <!-- creating an empty array -->
18
20
  <% title = [] %>
@@ -20,48 +22,19 @@
20
22
  <!-- creating an empty hash to store page fragments value -->
21
23
  <% page_fragment = Hash.new %>
22
24
 
23
- <!-- creating an empty hash to store page_parts value -->
24
- <% x = Hash.new %>
25
-
26
- <!-- creating an empty hash to store page_parts_pages value -->
27
- <% y = Hash.new %>
28
-
29
- <!-- declaring some local variables to be used as hash index in loop --%>
30
- <% i = 0 %>
31
-
32
25
  <!--
33
26
  looping through the array
34
27
  to display the link for different page parts
35
28
  -->
36
29
  <% @parts.each_with_index do |part, index| %>
37
30
 
38
- <li class='page-parts-li'>
31
+ <li class="page-parts-li ui-state-default ui-corner-top ui-state-active " >
39
32
 
40
- <%= link_to part, "#page-part-fields-#{index}" %>
33
+ <%= link_to part, "javascript:void(0)", :id => "#page-part-fields-#{index}" %>
41
34
  <% title[index] = part %>
42
35
 
43
36
  <!-- calling helper method to check existence of similar page parts -->
44
- <% page_fragment[index] = get_fragments(index, part) %>
45
-
46
- <!-- check if page_fragment is nil or empty -->
47
- <% if page_fragment[index].nil? or page_fragment[index].empty? or
48
- @page.title == @page.page_parts.find_by_title(part).pages.first.title %>
49
-
50
- <!-- store page_parts value -->
51
- <% x[i] = index %>
52
-
53
- <!-- increment local variables by 1 -->
54
- <% i = i+1 %>
55
-
56
- <% else %>
57
-
58
- <!-- store page_parts_pages value -->
59
- <% y[i] = index %>
60
-
61
- <!-- increment local variables by 1 -->
62
- <% i = i+1 %>
63
-
64
- <% end %>
37
+ <% page_fragment[index] = get_fragments(part) %>
65
38
 
66
39
  </li>
67
40
 
@@ -78,23 +51,23 @@
78
51
  <%= f.fields_for :page_parts do |p| %>
79
52
 
80
53
  <!-- check if page_fragment is nil or empty -->
81
- <% if not x[index].nil? %>
54
+ <% if page[title[index]].pages.first.title == @page.title %>
82
55
 
83
56
  <!-- if yes then render the partial for page_part -->
84
57
  <%= render 'mcms_pages/admin/pages/page_part_form_field',
85
58
  :f => p,
86
- :part_index => x[index],
87
- :title => title[x[index]]
59
+ :part_index => index,
60
+ :title => title[index]
88
61
  %>
89
62
 
90
- <%= p.hidden_field :id , :value => "#{@page.page_parts[x[index]].id}" unless x[index].nil? %>
63
+ <%= p.hidden_field :id , :value => "#{page[title[index]].id}" unless index.nil? %>
91
64
 
92
65
  <!-- increment index by 1 -->
93
66
  <% index += 1 %>
94
67
 
95
68
  <% else %>
96
69
 
97
- <%= p.hidden_field :id , :value => "#{@page.page_parts[x[index]].id}" unless x[index].nil? %>
70
+ <%= p.hidden_field :id , :value => "#{page[title[index]].id}" unless index.nil? %>
98
71
 
99
72
  <!-- increment index by 1 -->
100
73
  <% index += 1 %>
@@ -109,23 +82,23 @@
109
82
  <!-- rendering the form for association page_part_pages -->
110
83
  <%= f.fields_for :page_parts_pages do |p| %>
111
84
 
112
- <% if not y[loop_index].nil? and not (page_fragment[y[loop_index]].nil? and page_fragment[y[loop_index]].empty?) %>
85
+ <% if not page[title[loop_index]].pages.first.title == @page.title %>
113
86
 
114
87
  <%= render 'mcms_pages/admin/pages/page_part_page_form_field',
115
88
  :f => p,
116
- :part_index => y[loop_index],
117
- :fragment => page_fragment[y[loop_index]],
118
- :title => title[y[loop_index]]
89
+ :part_index => loop_index,
90
+ :fragment => page_fragment[loop_index],
91
+ :title => title[loop_index]
119
92
  %>
120
93
 
121
- <%= p.hidden_field :id , :value => "#{@page.page_parts_pages[y[loop_index]].id}" unless y[loop_index].nil? %>
94
+ <%= p.hidden_field :id , :value => "#{page[title[loop_index]].page_parts_pages.where(:page_id => @page.id).first.id}" unless loop_index.nil? %>
122
95
 
123
96
  <!-- increment loop_index by 1 -->
124
97
  <% loop_index += 1 %>
125
98
 
126
99
  <% else %>
127
100
 
128
- <%= p.hidden_field :id , :value => "#{@page.page_parts_pages[y[loop_index]].id}" unless y[loop_index].nil? %>
101
+ <%= p.hidden_field :id , :value => "#{page[title[loop_index]].page_parts_pages.where(:page_id => @page.id).first.id}" unless loop_index.nil? %>
129
102
 
130
103
  <!-- increment loop_index by 1 -->
131
104
  <% loop_index += 1 %>
@@ -0,0 +1,113 @@
1
+ <!--
2
+
3
+ @File Name : admin/pages/_page_part_form.html.erb
4
+ @Company Name : Mindfire Solutions Private Limited
5
+ @Creator Name : Vikram Kumar Mishra
6
+ @Date Created : 2012-07-03
7
+ @Date Modified :
8
+ @Last Modification Details :
9
+ @Purpose : To display the partial for page part edit form fields.
10
+
11
+ -->
12
+
13
+ <% page = arrange_page_part(@page) %>
14
+
15
+ <div id='page-tabs' class="page-tabs clearfix ui-tabs ui-widget ui-widget-content ui-corner-all" >
16
+
17
+ <ul id='page-parts-ul' class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" >
18
+
19
+ <!-- creating an empty array -->
20
+ <% title = [] %>
21
+
22
+ <!-- creating an empty hash to store page fragments value -->
23
+ <% page_fragment = Hash.new %>
24
+
25
+ <!--
26
+ looping through the array
27
+ to display the link for different page parts
28
+ -->
29
+ <% @parts.each_with_index do |part, index| %>
30
+
31
+ <li class="page-parts-li ui-state-default ui-corner-top ui-state-active " >
32
+
33
+ <%= link_to part, "#page-part-fields-#{index}" %>
34
+ <% title[index] = part %>
35
+
36
+ <!-- calling helper method to check existence of similar page parts -->
37
+ <% page_fragment[index] = get_fragments(index, part) %>
38
+
39
+ </li>
40
+
41
+ <% end %>
42
+
43
+ </ul>
44
+
45
+ <div id='page-part-form'>
46
+
47
+ <!-- initializing the variable to create a unique id for different page part fields -->
48
+ <% index = 0 %>
49
+
50
+ <!-- rendering the form for association page part -->
51
+ <%= f.fields_for :page_parts do |p| %>
52
+
53
+ <!-- check if page_fragment is nil or empty -->
54
+ <% if page[title[index]].pages.first.title == @page.title %>
55
+
56
+ <!-- if yes then render the partial for page_part -->
57
+ <%= render 'mcms_pages/admin/pages/page_part_form_field',
58
+ :f => p,
59
+ :part_index => index,
60
+ :title => title[index]
61
+ %>
62
+
63
+ <%= p.hidden_field :id , :value => "#{@page.page_parts[index].id}" unless index.nil? %>
64
+
65
+ <!-- increment index by 1 -->
66
+ <% index += 1 %>
67
+
68
+ <% else %>
69
+
70
+ <%= p.hidden_field :id , :value => "#{@page.page_parts[index].id}" unless index.nil? %>
71
+
72
+ <!-- increment index by 1 -->
73
+ <% index += 1 %>
74
+
75
+ <% end %>
76
+
77
+ <% end %>
78
+
79
+ <!-- initializing the variable to loop though the HASH page_fragment -->
80
+ <% loop_index = 0 %>
81
+
82
+ <!-- rendering the form for association page_part_pages -->
83
+ <%= f.fields_for :page_parts_pages do |p| %>
84
+
85
+ <% if not page[title[loop_index]].pages.first.title == @page.title %>
86
+
87
+ <%= render 'mcms_pages/admin/pages/page_part_page_form_field',
88
+ :f => p,
89
+ :part_index => loop_index,
90
+ :fragment => page_fragment[loop_index],
91
+ :title => title[loop_index]
92
+ %>
93
+
94
+ <%#= p.hidden_field :id , :value => "#{@page.page_parts_pages[loop_index].id}" unless loop_index.nil? %>
95
+
96
+ <!-- increment loop_index by 1 -->
97
+ <% loop_index += 1 %>
98
+
99
+ <% else %>
100
+
101
+ <%#= p.hidden_field :id , :value => "#{@page.page_parts_pages[loop_index].id}" unless loop_index.nil? %>
102
+
103
+ <!-- increment loop_index by 1 -->
104
+ <% loop_index += 1 %>
105
+
106
+ <% end %>
107
+
108
+ <% end %>
109
+
110
+ </div>
111
+
112
+ </div>
113
+
@@ -10,10 +10,10 @@
10
10
 
11
11
  -->
12
12
 
13
- <div id='page-tabs' class="page-tabs">
13
+ <div id='page-tabs' class="page-tabs clearfix ui-tabs ui-widget ui-widget-content ui-corner-all" >
14
14
 
15
15
 
16
- <ul id='page-parts-ul'>
16
+ <ul id='page-parts-ul' class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
17
17
 
18
18
  <!-- creating an empty array -->
19
19
  <% title = [] %>
@@ -37,13 +37,13 @@
37
37
  -->
38
38
  <% @parts.each_with_index do |part, index| %>
39
39
 
40
- <li class='page-parts-li'>
40
+ <li class="page-parts-li ui-state-default ui-corner-top ui-state-active ">
41
41
 
42
- <%= link_to part, "#page-part-fields-#{index}" %>
42
+ <%= link_to part, "javascript:void(0)", :id => "#page-part-fields-#{index}" %>
43
43
  <% title[index] = part %>
44
44
 
45
45
  <!-- calling helper method to check existence of similar page parts -->
46
- <% page_fragment[index] = get_fragments(index, part) %>
46
+ <% page_fragment[index] = get_fragments(part) %>
47
47
 
48
48
  <!-- check if page_fragment is nil or empty -->
49
49
  <% if page_fragment[index].nil? or page_fragment[index].empty? %>
@@ -0,0 +1,133 @@
1
+ <!--
2
+
3
+ @File Name : admin/pages/_page_part_form.html.erb
4
+ @Company Name : Mindfire Solutions Private Limited
5
+ @Creator Name : Vikram Kumar Mishra
6
+ @Date Created : 2012-06-07
7
+ @Date Modified : 2012-06-14
8
+ @Last Modification Details : 'mcms-' removed from css selectors
9
+ @Purpose : To display the partial for page part form fields.
10
+
11
+ -->
12
+
13
+ <div id='page-tabs' class="page-tabs clearfix ui-tabs ui-widget ui-widget-content ui-corner-all" >
14
+
15
+
16
+ <ul id='page-parts-ul' class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
17
+
18
+ <!-- creating an empty array -->
19
+ <% title = [] %>
20
+
21
+ <!-- creating an empty hash to store page fragments value -->
22
+ <% page_fragment = Hash.new %>
23
+
24
+ <!-- creating an empty hash to store page_parts value -->
25
+ <% x = Hash.new %>
26
+
27
+ <!-- creating an empty hash to store page_parts_pages value -->
28
+ <% y = Hash.new %>
29
+
30
+ <!-- declaring some local variables to be used as hash index in loop --%>
31
+ <% i = 0 %>
32
+ <% j = 0 %>
33
+
34
+ <!--
35
+ looping through the array
36
+ to display the link for different page parts
37
+ -->
38
+ <% @parts.each_with_index do |part, index| %>
39
+
40
+ <li class="page-parts-li ui-state-default ui-corner-top ui-state-active ">
41
+
42
+ <%= link_to part, "#page-part-fields-#{index}" %>
43
+ <% title[index] = part %>
44
+
45
+ <!-- calling helper method to check existence of similar page parts -->
46
+ <% page_fragment[index] = get_fragments(index, part) %>
47
+
48
+ <!-- check if page_fragment is nil or empty -->
49
+ <% if page_fragment[index].nil? or page_fragment[index].empty? %>
50
+
51
+ <!-- store page_parts value -->
52
+ <% x[i] = index %>
53
+
54
+ <!-- increment local variables by 1 -->
55
+ <% i = i+1 %>
56
+
57
+ <% else %>
58
+
59
+ <!-- store page_parts_pages value -->
60
+ <% y[j] = index %>
61
+
62
+ <!-- increment local variables by 1 -->
63
+ <% j = j+1 %>
64
+
65
+ <% end %>
66
+
67
+ </li>
68
+
69
+ <% end %>
70
+
71
+ </ul>
72
+
73
+ <div id='page-part-form'>
74
+
75
+ <!-- initializing the variable to create a unique id for different page part fields -->
76
+ <% index = 0 %>
77
+
78
+ <!-- rendering the form for association page part -->
79
+ <%= f.fields_for :page_parts do |p| %>
80
+
81
+ <!-- check if page_fragment is nil or empty -->
82
+ <% if not x[index].nil? and (page_fragment[x[index]].nil? or page_fragment[x[index]].empty?) %>
83
+
84
+ <!-- if yes then render the partial for page_part -->
85
+ <%= render 'mcms_pages/admin/pages/page_part_form_field',
86
+ :f => p,
87
+ :part_index => x[index],
88
+ :title => title[x[index]]
89
+ %>
90
+
91
+ <!-- increment index by 1 -->
92
+ <% index += 1 %>
93
+
94
+ <% else %>
95
+
96
+ <!-- increment index by 1 -->
97
+ <% index += 1 %>
98
+
99
+ <% end %>
100
+
101
+ <% end %>
102
+
103
+ <!-- initializing the variable to loop though the HASH page_fragment -->
104
+ <% loop_index = 0 %>
105
+
106
+ <!-- rendering the form for association page_part_pages -->
107
+ <%= f.fields_for :page_parts_pages do |p| %>
108
+
109
+ <% if not y[loop_index].nil? and not (page_fragment[y[loop_index]].nil? and page_fragment[y[loop_index]].empty?) %>
110
+
111
+ <%= render 'mcms_pages/admin/pages/page_part_page_form_field',
112
+ :f => p,
113
+ :part_index => y[loop_index],
114
+ :fragment => page_fragment[y[loop_index]],
115
+ :title => title[y[loop_index]]
116
+ %>
117
+
118
+ <!-- increment loop_index by 1 -->
119
+ <% loop_index += 1 %>
120
+
121
+ <% else %>
122
+
123
+ <!-- increment loop_index by 1 -->
124
+ <% loop_index += 1 %>
125
+
126
+ <% end %>
127
+
128
+ <% end %>
129
+
130
+ </div>
131
+
132
+ </div>
133
+
@@ -10,12 +10,42 @@
10
10
 
11
11
  -->
12
12
 
13
+ <% page = arrange_page_part(@page) unless @page.nil? %>
14
+
13
15
  <div id="page-part-fields-<%= part_index %>" class='page-part-fields'>
14
16
 
15
17
  <%= f.hidden_field :title, :value => "#{title}", :name => "page[page_parts_attributes][#{part_index}][title]" %>
16
- <%= f.cktext_area :body,
17
- :input_html => {:name => "page[page_parts_attributes][#{part_index}][body]",
18
- :id => "page_page_parts_attributes_#{part_index}_body"},
19
- :toolbar => 'Full', :width => 900, :height => 400 %>
20
-
21
- </div>
18
+
19
+ <%= f.hidden_field :id,
20
+ :name => "page[page_parts_attributes][#{part_index}][id]" unless controller.action_name != "add_page_part" %>
21
+
22
+ <% if @page.nil? %>
23
+
24
+ <%= f.cktext_area :body,
25
+ :input_html => {:name => "page[page_parts_attributes][#{part_index}][body]",
26
+ :id => "page_page_parts_attributes_#{part_index}_body"},
27
+ :toolbar => 'Full', :width => 900, :height => 400 %>
28
+
29
+ <% else %>
30
+
31
+ <%= f.cktext_area :body,
32
+ :input_html => { :value => "#{page[title].body}", :name => "page[page_parts_attributes][#{part_index}][body]",
33
+ :id => "page_page_parts_attributes_#{part_index}_body"},
34
+ :toolbar => 'Full', :width => 900, :height => 400
35
+ %>
36
+
37
+ <% end %>
38
+
39
+ <% unless title == "main body" %>
40
+
41
+ OR
42
+
43
+ <%= link_to "Choose Existing #{title}",
44
+ {:controller=>"pages", :action => 'add_page_part', :title => "#{title}", :index => "#{part_index}"},
45
+ :remote => true, :id => "create-page-part-page-link-#{part_index}", :class => "create-page-part-page-link"
46
+ %>
47
+
48
+ <% end %>
49
+
50
+ </div>
51
+
@@ -4,8 +4,8 @@
4
4
  @Company Name : Mindfire Solutions Private Limited
5
5
  @Creator Name : Vikram Kumar Mishra
6
6
  @Date Created : 2012-06-26
7
- @Date Modified :
8
- @Last Modification Details :
7
+ @Date Modified :
8
+ @Last Modification Details :
9
9
  @Purpose : To display page_part_pages form fields.
10
10
 
11
11
  -->
@@ -15,25 +15,15 @@
15
15
  <%= f.label :page_part_id, "Choose Existing #{title}",
16
16
  :id => "page_page_parts_pages_attributes_#{part_index}_page_part_id" %>
17
17
 
18
- <% if controller.action_name == 'new' or controller.action_name == 'create' %>
19
-
20
- <%= f.select(:page_part_id, fragment.collect {|p| [ "#{p[1]} #{title}", p[0] ] },{},
18
+ <%= f.select(:page_part_id, fragment.collect {|p| [ "#{p[1]} #{title}", p[0] ] },{},
21
19
  {:id => "page_page_parts_pages_attributes_#{part_index}_page_part_id",
22
20
  :name => "page[page_parts_pages_attributes][#{part_index}][page_part_id]"}) unless fragment.nil? %>
23
- OR
24
- <%= link_to "Create New #{title}",
25
- {:controller=>"pages", :action => 'add_page_part', :title => "#{title}", :index => "#{part_index}"},
26
- :remote => true,:id => "create-page-part-link-#{part_index}", :class => "create-page-part-link" %>
21
+ OR
27
22
 
28
- <%#= link_to "Create New #{title}", "javascript:void(0)",
29
- :id => "create-page-part-link-#{part_index}", :class => "create-page-part-link" %>
30
-
31
- <% else %>
23
+ <%= link_to "Create New #{title}",
24
+ {:controller=>"pages", :action => 'add_page_part',
25
+ :title => "#{title}", :index => "#{part_index}", :part => "page_part"},
26
+ :remote => true,:id => "create-page-part-link-#{part_index}", :class => "create-page-part-link" %>
32
27
 
33
- <%= f.select(:page_part_id, fragment.collect {|p| [ "#{p[1]} #{title}", p[0] ] },{:selected => @part_title[title]},
34
- {:id => "page_page_parts_pages_attributes_#{part_index}_page_part_id",
35
- :name => "page[page_parts_pages_attributes][#{part_index}][page_part_id]"}) unless fragment.nil? %>
28
+ </div>
36
29
 
37
- <% end %>
38
-
39
- </div>
@@ -12,12 +12,34 @@
12
12
 
13
13
  $(document).ready(function(){
14
14
 
15
- <%
15
+ <% if @part == "page_part" %>
16
+
17
+ <%
18
+ #calling helper method to create form object
19
+ builder = build_page_part(@index)
20
+ %>
21
+
22
+ $("#page_page_parts_pages_attributes_<%= @index %>__destroy").remove();
23
+ $("#page-part-fields-<%= @index %>").after('<%= hidden_field_tag "page[page_parts_pages_attributes][#{@index}][_destroy]", "1" %>');
24
+
25
+ var html = "<%= escape_javascript(render 'mcms_pages/admin/pages/page_part_form_field',
26
+ :part_index => @index, :f => builder, :title => @title) %>";
27
+
28
+ <% else %>
29
+
30
+ <%
16
31
  #calling helper method to create form object
17
- builder = build_page_part(@index)
18
- %>
32
+ builder = build_page_part_page(@index)
33
+ %>
34
+
35
+ <% fragment = get_fragments(@title) %>
36
+
37
+ var html = "<%= escape_javascript(render 'mcms_pages/admin/pages/page_part_page_form_field',
38
+ :part_index => @index, :f => builder, :title => @title, :fragment => fragment) %>";
39
+
40
+ $("#page_page_parts_pages_attributes_<%= @index %>__destroy").val("0");
19
41
 
20
- var html = "<%= escape_javascript(render 'mcms_pages/admin/pages/page_part_form_field', :part_index => @index, :f => builder, :title => @title) %>";
42
+ <% end %>
21
43
 
22
44
  $("#page-part-fields-<%= @index %>").html(html);
23
45
 
@@ -13,3 +13,5 @@
13
13
  <!-- render partial form.html.erb -->
14
14
  <%= render 'mcms_pages/admin/pages/form' %>
15
15
 
16
+ <%= render :partial => "mcms_pages/layouts/head" %>
17
+
@@ -10,7 +10,7 @@
10
10
  -->
11
11
 
12
12
  <p class="notice"> <%= notice %></p>
13
- <section id='pages-records' class='pages-tree'>
13
+ <div id='pages-records' class='pages-tree'>
14
14
 
15
15
  <ul id='page-sortable-list'>
16
16
 
@@ -19,8 +19,10 @@
19
19
 
20
20
  </ul>
21
21
 
22
- </section>
22
+ </div>
23
23
 
24
24
  <!-- render partial _action.html.erb -->
25
25
  <%= render 'mcms_pages/admin/pages/action' %>
26
26
 
27
+ <%= render :partial => "mcms_pages/layouts/head" %>
28
+
@@ -13,3 +13,5 @@
13
13
  <!-- render partial form.html.erb -->
14
14
  <%= render 'mcms_pages/admin/pages/form' %>
15
15
 
16
+ <%= render :partial => "mcms_pages/layouts/head" %>
17
+