Commit e1522026b959443d92b2fa5e1befd26f4620cb07

Authored by Karpikau Andrei
1 parent 722860b0

check save and cancel page, tags part, check small errors

... ... @@ -1348,6 +1348,31 @@ $('body').on('click', '.delete-image-from-list', function(){
1348 1348 return false;
1349 1349 });
1350 1350
  1351 +
  1352 +$('body').on('click', '.delete-tag-from-list', function(){
  1353 + var $this = $(this),
  1354 + url = $this.attr('href'),
  1355 + title = "Are you sure? If files are assigned to this tag, the assignment is removed.";
  1356 +
  1357 + bootbox.confirm(title, function(result) {
  1358 + if(result){
  1359 + jQuery.ajax({
  1360 + type: 'GET',
  1361 + url: url,
  1362 + dataType: 'json',
  1363 + success: function(data){
  1364 + if(data.status == 'ok'){
  1365 + $('.tag-item-' + data.id).remove();
  1366 + }
  1367 + }
  1368 +
  1369 + });
  1370 + }
  1371 + });
  1372 +
  1373 + return false;
  1374 +});
  1375 +
1351 1376 $('body').on('click', '.copy-to-memory', function(){
1352 1377 var str = $(this).data('str');
1353 1378 var el = document.createElement('textarea');
... ... @@ -2101,6 +2126,12 @@ jQuery(document).ready(function(){
2101 2126 });
2102 2127 }
2103 2128
  2129 + $this.find('.bootstrap-tagsinput').popover({
  2130 + trigger: 'manual',
  2131 + placement: 'top',
  2132 + content: 'Content',
  2133 + title: 'Title'
  2134 + });
2104 2135
2105 2136 $this.find('.filestyle').each(function() {
2106 2137 var $this = $(this), options = {
... ... @@ -2193,6 +2224,18 @@ jQuery(document).ready(function(){
2193 2224 }
2194 2225 });
2195 2226
  2227 + $('body').on('click', '.btn-form-reset', function(){
  2228 + $(this).closest('form').trigger('reset');
  2229 + return false;
  2230 + });
  2231 +
  2232 + $('.nav-tabs.tab-with-url-prefix a').on('shown.bs.tab', function(e){
  2233 + window.location.hash = e.target.hash;
  2234 + });
  2235 + var url = document.location.toString();
  2236 + if(url.match('#')){
  2237 + $('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
  2238 + }
2196 2239
2197 2240
2198 2241 });
... ...
... ... @@ -6,6 +6,7 @@ jQuery(document).ready(function(){
6 6 $('.html-generator').on('click', '.col-operation .col-edit', function(){
7 7 var $this = $(this),
8 8 $cell = $this.closest('.col'),
  9 + $block = $cell.closest('.html-generator'),
9 10 size = $cell.data('size'),
10 11 offset = $cell.data('offset'),
11 12 className = $cell.data('class');
... ... @@ -58,6 +59,8 @@ jQuery(document).ready(function(){
58 59
59 60 $this.popover('hide');
60 61
  62 + $block.find('.save').trigger('click');
  63 +
61 64 return false;
62 65 });
63 66
... ... @@ -69,11 +72,14 @@ jQuery(document).ready(function(){
69 72 $this.popover('dispose');
70 73 }).popover('show');
71 74
  75 +
72 76 return false;
73 77 });
74 78
75 79 $('.html-generator').on('click', '.col-operation .col-remove', function(){
76   - var $this = $(this);
  80 + var $this = $(this),
  81 + $block = $this.closest('.html-generator');
  82 +
77 83 bootbox.confirm('Are you sure?', function(result) {
78 84 if (result) {
79 85 var $cell = $this.closest('.col'),
... ... @@ -88,6 +94,7 @@ jQuery(document).ready(function(){
88 94 data: {structure_id: $cell.data('id')},
89 95 success: function (data) {
90 96 $cell.remove();
  97 + $block.find('.save').trigger('click');
91 98 }
92 99 });
93 100
... ... @@ -101,7 +108,9 @@ jQuery(document).ready(function(){
101 108
102 109
103 110 $('.html-generator').on('click', '.row-operation .row-remove', function(){
104   - var $this = $(this);
  111 + var $this = $(this),
  112 + $block = $this.closest('.html-generator');
  113 +
105 114 bootbox.confirm('Are you sure?', function(result) {
106 115 if (result) {
107 116 var $row = $this.closest('.row-fluid'),
... ... @@ -120,6 +129,7 @@ jQuery(document).ready(function(){
120 129 data: {structure_ids: mas_cell_id},
121 130 success: function (data) {
122 131 $row.remove();
  132 + $block.find('.save').trigger('click');
123 133 }
124 134 });
125 135 }
... ... @@ -131,6 +141,7 @@ jQuery(document).ready(function(){
131 141 data: {structure_id: $row.data('id')},
132 142 success: function (data) {
133 143 $row.remove();
  144 + $block.find('.save').trigger('click');
134 145 }
135 146 });
136 147 }
... ... @@ -284,7 +295,8 @@ jQuery(document).ready(function(){
284 295 });
285 296
286 297 $('.html-generator').on('click', '.col-operation .col-disable, .row-operation .col-disable', function(){
287   - var $this = $(this);
  298 + var $this = $(this),
  299 + $block = $this.closest('.html-generator');
288 300
289 301 if($this.closest('.row-element-block, .row-element-row').length > 0){
290 302 var $cell = $this.closest('.row-element-block, .row-element-row');
... ... @@ -302,6 +314,7 @@ jQuery(document).ready(function(){
302 314 $this.text('Disable');
303 315 }
304 316 $('body').trigger('click');
  317 + $block.find('.save').trigger('click');
305 318
306 319 return false;
307 320 });
... ... @@ -696,7 +709,7 @@ jQuery(document).ready(function(){
696 709 $obj.sortable({
697 710 items: ".col"
698 711 });
699   -
  712 + $block.find('.save').trigger('click');
700 713 }
701 714
702 715 }
... ... @@ -753,6 +766,7 @@ jQuery(document).ready(function(){
753 766 items: ".row-fluid"
754 767 });
755 768 }
  769 + $block.find('.save').trigger('click');
756 770 }
757 771 }
758 772 });
... ... @@ -816,7 +830,10 @@ jQuery(document).ready(function(){
816 830 url: url,
817 831 data: {content: JSON.stringify(res) },
818 832 success: function () {
819   - alert('Success save');
  833 + $.notify('Success save', {
  834 + status: 'info',
  835 + pos:"top-right"
  836 + });
820 837 }
821 838 });
822 839
... ...
... ... @@ -29,20 +29,22 @@ jQuery(document).ready(function(){
29 29 if($('.image-list').length > 0){
30 30 var $wrapper = $('.image-list');
31 31 loadImage($wrapper);
32   - $wrapper.find('.filter label').click(function(){
33   - var $this = $(this);
34   - if($this.hasClass('active')){
35   - $this.removeClass('active');
36   - }else{
37   - $this.addClass('active');
  32 + $wrapper.find('.filter label').click(function(e){
  33 + if(e.target.tagName != 'A'){
  34 + var $this = $(this);
  35 + if($this.hasClass('active')){
  36 + $this.removeClass('active');
  37 + }else{
  38 + $this.addClass('active');
  39 + }
  40 + if($this.data('value') == 'all' && $this.hasClass('active')){
  41 + $wrapper.find(".filter label.active").not($this).removeClass('active');
  42 + };
  43 + if($this.data('value') != 'all' && $this.hasClass('active')){
  44 + $wrapper.find(".filter label.active[data-value=all]").removeClass('active');
  45 + };
  46 + loadImage($wrapper);
38 47 }
39   - if($this.data('value') == 'all' && $this.hasClass('active')){
40   - $wrapper.find(".filter label.active").not($this).removeClass('active');
41   - };
42   - if($this.data('value') != 'all' && $this.hasClass('active')){
43   - $wrapper.find(".filter label.active[data-value=all]").removeClass('active');
44   - };
45   - loadImage($wrapper);
46 48 });
47 49 }
48 50
... ...
... ... @@ -250,7 +250,6 @@
250 250 val = $.map(self.items(), function(item) {
251 251 return self.options.itemValue(item).toString();
252 252 });
253   -
254 253 self.$element.val(val, true).trigger('change');
255 254 },
256 255
... ... @@ -353,6 +352,7 @@
353 352
354 353 if (self.options.addOnBlur && self.options.freeInput) {
355 354 self.$input.on('focusout', $.proxy(function(event) {
  355 +
356 356 // HACK: only process on focusout when no typeahead opened, to
357 357 // avoid adding the typeahead text as tag
358 358 if ($('.typeahead, .twitter-typeahead', self.$container).length === 0) {
... ... @@ -419,11 +419,11 @@
419 419 var textLength = $input.val().length,
420 420 wordSpace = Math.ceil(textLength / 5),
421 421 size = textLength + wordSpace + 1;
422   - $input.attr('size', Math.max(this.inputSize, $input.val().length));
  422 + $input.attr('size', Math.max(this.inputSize, size ));
423 423 }, self));
424 424
425 425 self.$container.on('keypress', 'input', $.proxy(function(event) {
426   - event.stopPropagation();
  426 + //event.stopPropagation();
427 427 var $input = $(event.target);
428 428
429 429 if (self.$element.attr('disabled')) {
... ... @@ -449,7 +449,7 @@
449 449 var textLength = $input.val().length,
450 450 wordSpace = Math.ceil(textLength / 5),
451 451 size = textLength + wordSpace + 1;
452   - $input.attr('size', Math.max(this.inputSize, $input.val().length));
  452 + $input.attr('size', Math.max(this.inputSize, size));
453 453 if(keyCombinationInList(event, [13]) ){
454 454 return false;
455 455 }else{
... ...
... ... @@ -1484,7 +1484,8 @@
1484 1484 this._checkLanguageDirection();
1485 1485 },
1486 1486 resetInputValue: function resetInputValue() {
1487   - this.setInputValue(this.query);
  1487 + //this.setInputValue(this.query);
  1488 + this.setInputValue('');
1488 1489 },
1489 1490 getHint: function getHint() {
1490 1491 return this.$hint.val();
... ...
... ... @@ -45,4 +45,9 @@
45 45
46 46 .gray-theme.fr-toolbar .fr-command.fr-btn.fr-disabled, .gray-theme.fr-popup .fr-command.fr-btn.fr-disabled{
47 47
48   -}
\ No newline at end of file
  48 +}
  49 +
  50 +.filter .btn-group-toggle > .btn{margin-bottom:5px;position:relative;}
  51 +.filter .btn-group-toggle > .btn a, .filter .btn-group-toggle > .btn a:hover{text-decoration:none;position:absolute;top:-14px;right:2px;font-size:14px;line-height:14px;}
  52 +.filter .btn-group-toggle > .btn a{display:none;}
  53 +.filter .btn-group-toggle > .btn:hover a{display:inline;}
\ No newline at end of file
... ...
... ... @@ -83,7 +83,7 @@ module Kanjai
83 83 end
84 84 end
85 85
86   - redirect_to admin_pages_path(domain_id: @page.domain.id)
  86 + redirect_to :action => :edit, lang: params[:lang]
87 87 else
88 88 render :action => :edit, lang: params[:lang]
89 89 end
... ... @@ -192,7 +192,7 @@ module Kanjai
192 192 @step = 'meta'
193 193
194 194 if @page_data.update(permitted_params[:page_datum])
195   - redirect_to :action => :index
  195 + redirect_to edit_admin_page_url(@page, lang: params[:lang]) + '#meta'
196 196 else
197 197 render :action => :edit, lang: params[:lang]
198 198 end
... ...
... ... @@ -3,5 +3,13 @@ module Kanjai
3 3 def index
4 4 render json: ActsAsTaggableOn::Tag.order(:name).collect{|item| {title: item.name}}
5 5 end
  6 +
  7 + def delete
  8 + tag = ActsAsTaggableOn::Tag.where(id: params[:id].to_i).first
  9 + if tag
  10 + tag.destroy
  11 + end
  12 + render json: {status: 'ok', id: tag.id}
  13 + end
6 14 end
7 15 end
\ No newline at end of file
... ...
... ... @@ -32,6 +32,7 @@
32 32 <label class="col-md-2 col-form-label">Tags</label>
33 33 <div class="col-md-10">
34 34 <%= f.text_field :tag_list, class: 'form-control', data: {role: 'tagsinput'}, value: f.object.tag_list.join(', ') %>
  35 + <div class="form-text"><%= t('tag_input_help_text') %></div>
35 36 </div>
36 37 </div>
37 38 </fieldset>
... ...
... ... @@ -29,7 +29,10 @@
29 29 <div class="btn-group-toggle">
30 30 <label data-value='all' class="btn btn-primary active">All</label>
31 31 <% ActsAsTaggableOn::Tag.most_used.each do |tag| %>
32   - <label data-value='<%= tag.name %>' class="btn btn-primary"><%= tag.name %></label>
  32 + <label data-value='<%= tag.name %>' class="btn btn-primary tag-item-<%= tag.id %>">
  33 + <%= tag.name %>
  34 + <a class="delete-tag-from-list" href="<%= url_for(controller: 'tags', action: 'delete', id: tag.id) %>"><i class="fa fa-times"></i></a>
  35 + </label>
33 36 <% end %>
34 37 </div>
35 38 </div>
... ...
1 1 <div role="tabpanel">
2 2 <!-- Nav tabs-->
3 3 <% unless @page.new_record? %>
4   - <ul class="nav nav-tabs" role="tablist">
  4 + <ul class="nav nav-tabs tab-with-url-prefix" role="tablist">
5 5 <li class="nav-item" role="presentation"><a class="nav-link <%= @step == 'general' ? 'active' : '' %>" href="#general" aria-controls="general" role="tab" data-toggle="tab">General</a></li>
6 6 <li class="nav-item" role="presentation"><a class="nav-link <%= @step == 'meta' ? 'active' : '' %>" href="#meta" aria-controls="meta" role="tab" data-toggle="tab">Meta</a></li>
7 7 <li class="nav-item" role="presentation"><a class="nav-link" href="#content" aria-controls="content" role="tab" data-toggle="tab">Content</a></li>
... ...
... ... @@ -16,10 +16,9 @@
16 16 <div class="item label label-default element-block btn btn-primary"><%= t('admin.page_structure.block') %></div>
17 17 </div>
18 18
19   - <div class="card-footer mt-20">
  19 + <div class="card-footer not-visible">
20 20 <div class="clearfix">
21 21 <div class="float-right">
22   - <%= link_to t('actions.cancel'), admin_pages_url(domain_id: @page.domain.id), class: 'btn btn-secondary' %>
23 22 <button class="btn btn-primary save" type="submit"><%= t('actions.save') %></button>
24 23 </div>
25 24 </div>
... ...
... ... @@ -91,7 +91,7 @@
91 91 </div>
92 92 <div class="col-md-6">
93 93 <div class="float-right">
94   - <%= link_to t('actions.cancel'), admin_pages_url(domain_id: @page.domain.id), class: 'btn btn-secondary' %>
  94 + <%= link_to t('actions.reset'), 'javascript:void(0)', class: 'btn btn-secondary btn-form-reset' %>
95 95 <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button>
96 96 </div>
97 97 </div>
... ...
... ... @@ -28,7 +28,7 @@
28 28 <div class="card-footer mt-20">
29 29 <div class="clearfix">
30 30 <div class="float-right">
31   - <%= link_to t('actions.cancel'), admin_pages_url(domain_id: @page.domain.id), class: 'btn btn-secondary' %>
  31 + <%= link_to t('actions.reset'), 'javascript:void(0)', class: 'btn btn-secondary btn-form-reset' %>
32 32 <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button>
33 33 </div>
34 34 </div>
... ...
... ... @@ -45,6 +45,7 @@ en:
45 45 password_reset_error: "Can not send instrution, please check email"
46 46 rte_choose_image: "Choose Image"
47 47 add_alternative_domain: "Add Alternative Domain"
  48 + tag_input_help_text: "Type the name of the tag and finish the input with enter"
48 49
49 50
50 51 date:
... ... @@ -122,6 +123,7 @@ en:
122 123 back_to_choose_image: "Back to choose image"
123 124 choose_file: "Choose File"
124 125 remove_file: "Remove File"
  126 + reset: "Reset"
125 127
126 128 admin:
127 129 page_structure:
... ...
... ... @@ -22,6 +22,7 @@ Kanjai::Engine.routes.draw do
22 22 post 'page_contents/delete_item' => "page_contents#delete_item"
23 23 post 'page_contents/sorting' => "page_contents#sorting"
24 24 get 'tags' => 'tags#index'
  25 + get 'remove-tag' => 'tags#delete'
25 26
26 27 resources :admin_users
27 28
... ...
1 1 module Kanjai
2   - VERSION = "0.0.231"
  2 + VERSION = "0.0.232"
3 3 end
... ...