Commit 722860b0a5b51c2fdc0884d0a5f69f5284f6cd05

Authored by Karpikau Andrei
1 parent 65f72ad7

check bugs about update file and tags

@@ -1602,16 +1602,40 @@ var clearAjaxFileUpload = function(selector){ @@ -1602,16 +1602,40 @@ var clearAjaxFileUpload = function(selector){
1602 selector.find('.ajax-file-upload-form').unbind('submit'); 1602 selector.find('.ajax-file-upload-form').unbind('submit');
1603 }; 1603 };
1604 1604
  1605 +var loadTags = function(callback){
  1606 + $.get('/admin/tags', {}, function(data){
  1607 + callback(data);
  1608 + });
  1609 +}
  1610 +
  1611 +
  1612 +var substringMatcher = function(strs) {
  1613 + return function findMatches(q, cb) {
  1614 + var matches, substringRegex;
  1615 +
  1616 + // an array that will be populated with substring matches
  1617 + matches = [];
  1618 +
  1619 + // regex used to determine if a string contains the substring `q`
  1620 + var substrRegex = new RegExp(q, 'i');
  1621 +
  1622 + // iterate through the pool of strings and for any string that
  1623 + // contains the substring `q`, add it to the `matches` array
  1624 + $.each(strs, function(i, str) {
  1625 + if (substrRegex.test(str.title)) {
  1626 + matches.push(str);
  1627 + }
  1628 + });
  1629 + cb(matches);
  1630 + };
  1631 +};
  1632 +
1605 1633
1606 var tagnames = new Bloodhound({ 1634 var tagnames = new Bloodhound({
1607 datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'), 1635 datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'),
1608 queryTokenizer: Bloodhound.tokenizers.whitespace, 1636 queryTokenizer: Bloodhound.tokenizers.whitespace,
1609 prefetch: { 1637 prefetch: {
1610 - url: '/admin/tags',  
1611 - filter: function(list) {  
1612 - return $.map(list, function(title) {  
1613 - return { title: title }; });  
1614 - } 1638 + url: '/admin/tags'
1615 } 1639 }
1616 }); 1640 });
1617 tagnames.initialize(); 1641 tagnames.initialize();
@@ -1947,14 +1971,24 @@ jQuery(document).ready(function(){ @@ -1947,14 +1971,24 @@ jQuery(document).ready(function(){
1947 1971
1948 1972
1949 1973
1950 - $template.find("input[data-role=tagsinput]").tagsinput({  
1951 - typeaheadjs: {  
1952 - name: 'title',  
1953 - displayKey: 'title',  
1954 - valueKey: 'title',  
1955 - source: tagnames.ttAdapter()  
1956 - } 1974 +
  1975 +
  1976 + if($template.find("input[data-role=tagsinput]").length > 0){
  1977 + loadTags(function(data){
  1978 + $template.find("input[data-role=tagsinput]").tagsinput({
  1979 + typeaheadjs: {
  1980 + name: 'title',
  1981 + minLength: 0,
  1982 + displayKey: 'title',
  1983 + valueKey: 'title',
  1984 + source: substringMatcher(data),
  1985 + limit: 1000
  1986 + },
  1987 + maxChars: 0
  1988 + });
1957 }); 1989 });
  1990 + }
  1991 +
1958 }else{ 1992 }else{
1959 $('#gallery_form form #new_images').append($fileInput); 1993 $('#gallery_form form #new_images').append($fileInput);
1960 } 1994 }
@@ -2049,14 +2083,25 @@ jQuery(document).ready(function(){ @@ -2049,14 +2083,25 @@ jQuery(document).ready(function(){
2049 2083
2050 var $modal = $data.modal({show: false, keyboard: false, backdrop: 'static'}).on('shown.bs.modal', function (e) { 2084 var $modal = $data.modal({show: false, keyboard: false, backdrop: 'static'}).on('shown.bs.modal', function (e) {
2051 var $this = $(this); 2085 var $this = $(this);
2052 - $this.find("input[data-role=tagsinput]").tagsinput({  
2053 - typeaheadjs: {  
2054 - name: 'title',  
2055 - displayKey: 'title',  
2056 - valueKey: 'title',  
2057 - source: tagnames.ttAdapter()  
2058 - }  
2059 - }); 2086 +
  2087 +
  2088 + if($this.find("input[data-role=tagsinput]").length > 0){
  2089 + loadTags(function(data){
  2090 + $this.find("input[data-role=tagsinput]").tagsinput({
  2091 + typeaheadjs: {
  2092 + name: 'title',
  2093 + minLength: 0,
  2094 + displayKey: 'title',
  2095 + valueKey: 'title',
  2096 + source: substringMatcher(data),
  2097 + limit: 1000
  2098 + },
  2099 + maxChars: 0
  2100 + });
  2101 + });
  2102 + }
  2103 +
  2104 +
2060 $this.find('.filestyle').each(function() { 2105 $this.find('.filestyle').each(function() {
2061 var $this = $(this), options = { 2106 var $this = $(this), options = {
2062 'input' : $this.attr('data-input') !== 'false', 2107 'input' : $this.attr('data-input') !== 'false',
@@ -2086,6 +2131,7 @@ jQuery(document).ready(function(){ @@ -2086,6 +2131,7 @@ jQuery(document).ready(function(){
2086 if(data.status == 'ok'){ 2131 if(data.status == 'ok'){
2087 $('.modal').modal('hide'); 2132 $('.modal').modal('hide');
2088 $('#gallery_image_' + data.id).find('.card-img-top').attr('src', data.link); 2133 $('#gallery_image_' + data.id).find('.card-img-top').attr('src', data.link);
  2134 + $('#gallery_image_' + data.id).find('.card-title').text(data.title);
2089 }else{ 2135 }else{
2090 $this.find('.error-message').html(data.message); 2136 $this.find('.error-message').html(data.message);
2091 } 2137 }
@@ -2081,6 +2081,7 @@ @@ -2081,6 +2081,7 @@
2081 this.isActive() && this.open(); 2081 this.isActive() && this.open();
2082 }, 2082 },
2083 _minLengthMet: function minLengthMet(query) { 2083 _minLengthMet: function minLengthMet(query) {
  2084 + return true;
2084 query = _.isString(query) ? query : this.input.getQuery() || ""; 2085 query = _.isString(query) ? query : this.input.getQuery() || "";
2085 return query.length >= this.minLength; 2086 return query.length >= this.minLength;
2086 }, 2087 },
@@ -38,6 +38,11 @@ @@ -38,6 +38,11 @@
38 padding-left:20px; 38 padding-left:20px;
39 } 39 }
40 40
  41 +.tt-dataset{
  42 + max-height: 200px;
  43 + overflow-y: scroll;
  44 +}
  45 +
41 .gray-theme.fr-toolbar .fr-command.fr-btn.fr-disabled, .gray-theme.fr-popup .fr-command.fr-btn.fr-disabled{ 46 .gray-theme.fr-toolbar .fr-command.fr-btn.fr-disabled, .gray-theme.fr-popup .fr-command.fr-btn.fr-disabled{
42 47
43 } 48 }
@@ -34,7 +34,7 @@ module Kanjai @@ -34,7 +34,7 @@ module Kanjai
34 @file.resize! 34 @file.resize!
35 35
36 end 36 end
37 - render json: {status: 'ok', id: @file.id, link: @file.preview_link} 37 + render json: {status: 'ok', id: @file.id, link: @file.preview_link, title: @file.title}
38 else 38 else
39 render json: {status: 'error', message: @file.errors.full_message} 39 render json: {status: 'error', message: @file.errors.full_message}
40 end 40 end
1 module Kanjai 1 module Kanjai
2 class Admin::TagsController < AdminController 2 class Admin::TagsController < AdminController
3 def index 3 def index
4 - render json: ActsAsTaggableOn::Tag.order(:name).pluck(:name) 4 + render json: ActsAsTaggableOn::Tag.order(:name).collect{|item| {title: item.name}}
5 end 5 end
6 end 6 end
7 end 7 end
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 <div class="form-group row"> 31 <div class="form-group row">
32 <label class="col-md-2 col-form-label">Tags</label> 32 <label class="col-md-2 col-form-label">Tags</label>
33 <div class="col-md-10"> 33 <div class="col-md-10">
34 - <%= f.text_field :tag_list, class: 'form-control', data: {role: 'tagsinput'} %> 34 + <%= f.text_field :tag_list, class: 'form-control', data: {role: 'tagsinput'}, value: f.object.tag_list.join(', ') %>
35 </div> 35 </div>
36 </div> 36 </div>
37 </fieldset> 37 </fieldset>
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 </div> 26 </div>
27 </div> 27 </div>
28 <div class="card-body"> 28 <div class="card-body">
29 - <div class="table-responsive"> 29 + <div class="">
30 <div class="nestable-page-list dd dd-full-width page-list"> 30 <div class="nestable-page-list dd dd-full-width page-list">
31 <ol class="dd-list"> 31 <ol class="dd-list">
32 <%= render partial: 'kanjai/admin/pages/page_block', locals: {collection: domain.pages.where(parent: nil).order(:position)} %> 32 <%= render partial: 'kanjai/admin/pages/page_block', locals: {collection: domain.pages.where(parent: nil).order(:position)} %>
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.230" 2 + VERSION = "0.0.231"
3 end 3 end