Commit 28f9e0b63fd69406e360b4ccb29507c5425780e3

Authored by Karpikau Andrei
1 parent c5a4cec1

add new content type - textarea, show names and not markers inside admin panel, …

…start work on duplicate functon errors
@@ -240,6 +240,7 @@ jQuery(document).ready(function(){ @@ -240,6 +240,7 @@ jQuery(document).ready(function(){
240 $newCell.data('id', getNextStructureIdGLobal($block.find('.html-content'))); 240 $newCell.data('id', getNextStructureIdGLobal($block.find('.html-content')));
241 }else{ 241 }else{
242 $newCell.data('id', data.id); 242 $newCell.data('id', data.id);
  243 + $newCell.attr('data-id', data.id);
243 } 244 }
244 $cell.after($newCell); 245 $cell.after($newCell);
245 $block.find('.save').trigger('click'); 246 $block.find('.save').trigger('click');
@@ -31,7 +31,7 @@ module Kanjai @@ -31,7 +31,7 @@ module Kanjai
31 exist_markers = @page_template.page_content_markers.where(lang: lang).collect(&:marker) 31 exist_markers = @page_template.page_content_markers.where(lang: lang).collect(&:marker)
32 32
33 @page_template.template_statics.where.not(marker: exist_markers).each do |item| 33 @page_template.template_statics.where.not(marker: exist_markers).each do |item|
34 - @page_template.page_content_markers.create( 34 + obj = @page_template.page_content_markers.create(
35 marker: item.marker, 35 marker: item.marker,
36 marker_type: item.marker_type, 36 marker_type: item.marker_type,
37 marker_name: item.marker_name, 37 marker_name: item.marker_name,
@@ -39,8 +39,6 @@ module Kanjai @@ -39,8 +39,6 @@ module Kanjai
39 ) 39 )
40 end 40 end
41 41
42 -  
43 -  
44 @markers = @page_template.page_content_markers.where(lang: lang) 42 @markers = @page_template.page_content_markers.where(lang: lang)
45 end 43 end
46 44
@@ -55,14 +55,16 @@ module Kanjai @@ -55,14 +55,16 @@ module Kanjai
55 (1..count_repeat).each do |index| 55 (1..count_repeat).each do |index|
56 self.page_content_markers.create({ 56 self.page_content_markers.create({
57 marker: item[:name], 57 marker: item[:name],
58 - row_item: index 58 + row_item: index,
  59 + marker_name: item[:itemName]
59 }) 60 })
60 end 61 end
61 end 62 end
62 else 63 else
63 64
64 self.page_content_markers.create({ 65 self.page_content_markers.create({
65 - marker: item[:name] 66 + marker: item[:name],
  67 + marker_name: item[:itemName]
66 }) 68 })
67 end 69 end
68 end 70 end
@@ -97,7 +99,8 @@ module Kanjai @@ -97,7 +99,8 @@ module Kanjai
97 if item[:attributes]['repeat'].to_s == 'true' 99 if item[:attributes]['repeat'].to_s == 'true'
98 self.page_content_markers.create({ 100 self.page_content_markers.create({
99 marker: item[:name], 101 marker: item[:name],
100 - row_item: row_item 102 + row_item: row_item,
  103 + marker_name: item[:itemName]
101 }) 104 })
102 end 105 end
103 106
@@ -140,7 +143,11 @@ module Kanjai @@ -140,7 +143,11 @@ module Kanjai
140 else 143 else
141 page_template = self.page.page_template 144 page_template = self.page.page_template
142 subpart = TemplatePart.find_by_code(self.type_content) 145 subpart = TemplatePart.find_by_code(self.type_content)
143 - html = Kanjai::TemplateGenerator.subpart_generate(page_template, 'content', subpart.elements, self.marker_hash, self.id) 146 + if subpart
  147 + html = Kanjai::TemplateGenerator.subpart_generate(page_template, 'content', subpart.elements, self.marker_hash, self.id)
  148 + else
  149 + html = ''
  150 + end
144 html 151 html
145 end 152 end
146 end 153 end
1 module Kanjai 1 module Kanjai
2 class PageContentMarker < ActiveRecord::Base 2 class PageContentMarker < ActiveRecord::Base
3 - belongs_to :page_content 3 + belongs_to :page_content, optional: true
4 4
5 belongs_to :reference, polymorphic: true, optional: true 5 belongs_to :reference, polymorphic: true, optional: true
6 6
@@ -9,9 +9,6 @@ module Kanjai @@ -9,9 +9,6 @@ module Kanjai
9 "page-content-marker/#{self.id}/" 9 "page-content-marker/#{self.id}/"
10 end 10 end
11 11
12 -  
13 -  
14 -  
15 def get_marker_type(type_content) 12 def get_marker_type(type_content)
16 page_content = self.page_content 13 page_content = self.page_content
17 template = page_content.page.page_template 14 template = page_content.page.page_template
@@ -22,13 +22,16 @@ @@ -22,13 +22,16 @@
22 <% @obj.page_content_markers.select{|item| item.row_item == @row_item}.each_with_index do |item, index| %> 22 <% @obj.page_content_markers.select{|item| item.row_item == @row_item}.each_with_index do |item, index| %>
23 <%= form.fields_for :page_content_markers, item, child_index: (@current_row + index) do |form2| %> 23 <%= form.fields_for :page_content_markers, item, child_index: (@current_row + index) do |form2| %>
24 <div class="form-group"> 24 <div class="form-group">
25 - <%= form2.label :text_value, form2.object.marker, :class => "control-label" %> 25 + <%= form2.label :text_value, form2.object.marker_name || form2.object.marker, :class => "control-label" %>
26 <% if form2.object.get_marker_type(@obj.type_content) == 'string' %> 26 <% if form2.object.get_marker_type(@obj.type_content) == 'string' %>
27 <%= form2.text_field :text_value, :class => "form-control" %> 27 <%= form2.text_field :text_value, :class => "form-control" %>
28 <% end %> 28 <% end %>
29 <% if form2.object.get_marker_type(@obj.type_content) == 'text' %> 29 <% if form2.object.get_marker_type(@obj.type_content) == 'text' %>
30 <%= form2.text_area :text_value, :class => "form-control page_html_content" %> 30 <%= form2.text_area :text_value, :class => "form-control page_html_content" %>
31 <% end %> 31 <% end %>
  32 + <% if form2.object.get_marker_type(@obj.type_content) == 'textarea' %>
  33 + <%= form2.text_area :text_value, :class => "form-control" %>
  34 + <% end %>
32 <% if form2.object.get_marker_type(@obj.type_content) == 'file' %> 35 <% if form2.object.get_marker_type(@obj.type_content) == 'file' %>
33 <% s3_direct_post = S3_BUCKET.presigned_post(key: "#{form2.object.get_file_path}${filename}", success_action_status: '201', acl: 'public-read') %> 36 <% s3_direct_post = S3_BUCKET.presigned_post(key: "#{form2.object.get_file_path}${filename}", success_action_status: '201', acl: 'public-read') %>
34 <%= form2.file_field :text_value, :class => "", 'data-url' => s3_direct_post.url, 'data-form-data' => s3_direct_post.fields.to_json, 'data-host' => URI.parse(s3_direct_post.url).host , 'data-type' => 'zip' %> 37 <%= form2.file_field :text_value, :class => "", 'data-url' => s3_direct_post.url, 'data-form-data' => s3_direct_post.fields.to_json, 'data-host' => URI.parse(s3_direct_post.url).host , 'data-type' => 'zip' %>
@@ -30,13 +30,16 @@ @@ -30,13 +30,16 @@
30 <%= form.fields_for :page_content_markers, @markers do |form2| %> 30 <%= form.fields_for :page_content_markers, @markers do |form2| %>
31 31
32 <div class="form-group"> 32 <div class="form-group">
33 - <%= form2.label :text_value, form2.object.marker, :class => "control-label" %> 33 + <%= form2.label :text_value, form2.object.marker_name, :class => "control-label" %>
34 <% if form2.object.marker_type == 'string' %> 34 <% if form2.object.marker_type == 'string' %>
35 <%= form2.text_field :text_value, :class => "form-control" %> 35 <%= form2.text_field :text_value, :class => "form-control" %>
36 <% end %> 36 <% end %>
37 <% if form2.object.marker_type == 'text' %> 37 <% if form2.object.marker_type == 'text' %>
38 <%= form2.text_area :text_value, :class => "form-control page_html_content" %> 38 <%= form2.text_area :text_value, :class => "form-control page_html_content" %>
39 <% end %> 39 <% end %>
  40 + <% if form2.object.marker_type == 'textarea' %>
  41 + <%= form2.text_area :text_value, :class => "form-control" %>
  42 + <% end %>
40 <% if form2.object.marker_type == 'file' %> 43 <% if form2.object.marker_type == 'file' %>
41 <% s3_direct_post = S3_BUCKET.presigned_post(key: "#{form2.object.get_file_path}${filename}", success_action_status: '201', acl: 'public-read') %> 44 <% s3_direct_post = S3_BUCKET.presigned_post(key: "#{form2.object.get_file_path}${filename}", success_action_status: '201', acl: 'public-read') %>
42 <%= form2.file_field :text_value, :class => "", 'data-url' => s3_direct_post.url, 'data-form-data' => s3_direct_post.fields.to_json, 'data-host' => URI.parse(s3_direct_post.url).host , 'data-type' => 'zip' %> 45 <%= form2.file_field :text_value, :class => "", 'data-url' => s3_direct_post.url, 'data-form-data' => s3_direct_post.fields.to_json, 'data-host' => URI.parse(s3_direct_post.url).host , 'data-type' => 'zip' %>
1 <%= fields_for @obj do |form| %> 1 <%= fields_for @obj do |form| %>
2 <%= form.fields_for :page_content_markers, @obj.page_content_markers.where(:row_item => 0).order('id') do |form2| %> 2 <%= form.fields_for :page_content_markers, @obj.page_content_markers.where(:row_item => 0).order('id') do |form2| %>
3 <div class="form-group"> 3 <div class="form-group">
4 - <%= form2.label :text_value, form2.object.marker, :class => "control-label" %> 4 + <%= form2.label :text_value, form2.object.marker_name || form2.object.marker, :class => "control-label" %>
5 <% if form2.object.get_marker_type(@type_content) == 'string' %> 5 <% if form2.object.get_marker_type(@type_content) == 'string' %>
6 <%= form2.text_field :text_value, :class => "form-control" %> 6 <%= form2.text_field :text_value, :class => "form-control" %>
7 <% end %> 7 <% end %>
8 <% if form2.object.get_marker_type(@type_content) == 'text' %> 8 <% if form2.object.get_marker_type(@type_content) == 'text' %>
9 <%= form2.text_area :text_value, :class => "form-control page_html_content" %> 9 <%= form2.text_area :text_value, :class => "form-control page_html_content" %>
10 <% end %> 10 <% end %>
  11 + <% if form2.object.get_marker_type(@type_content) == 'textarea' %>
  12 + <%= form2.text_area :text_value, :class => "form-control" %>
  13 + <% end %>
11 <% if form2.object.get_marker_type(@type_content) == 'file' %> 14 <% if form2.object.get_marker_type(@type_content) == 'file' %>
12 <%= form2.hidden_field :text_value %> 15 <%= form2.hidden_field :text_value %>
13 <div class="preview"> 16 <div class="preview">
@@ -98,13 +101,16 @@ @@ -98,13 +101,16 @@
98 <div class="panel-body"> 101 <div class="panel-body">
99 <%= form.fields_for :page_content_markers, @obj.page_content_markers.where(:row_item => index).order('id') do |form2| %> 102 <%= form.fields_for :page_content_markers, @obj.page_content_markers.where(:row_item => index).order('id') do |form2| %>
100 <div class="form-group"> 103 <div class="form-group">
101 - <%= form2.label :text_value, form2.object.marker, :class => "control-label" %> 104 + <%= form2.label :text_value, form2.object.marker_name || form2.object.marker, :class => "control-label" %>
102 <% if form2.object.get_marker_type(@type_content) == 'string' %> 105 <% if form2.object.get_marker_type(@type_content) == 'string' %>
103 <%= form2.text_field :text_value, :class => "form-control" %> 106 <%= form2.text_field :text_value, :class => "form-control" %>
104 <% end %> 107 <% end %>
105 <% if form2.object.get_marker_type(@type_content) == 'text' %> 108 <% if form2.object.get_marker_type(@type_content) == 'text' %>
106 <%= form2.text_area :text_value, :class => "form-control page_html_content" %> 109 <%= form2.text_area :text_value, :class => "form-control page_html_content" %>
107 <% end %> 110 <% end %>
  111 + <% if form2.object.get_marker_type(@type_content) == 'textarea' %>
  112 + <%= form2.text_area :text_value, :class => "form-control" %>
  113 + <% end %>
108 <% if form2.object.get_marker_type(@type_content) == 'file' %> 114 <% if form2.object.get_marker_type(@type_content) == 'file' %>
109 <%= form2.hidden_field :text_value %> 115 <%= form2.hidden_field :text_value %>
110 <div class="preview"> 116 <div class="preview">
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.169" 2 + VERSION = "0.0.170"
3 end 3 end