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