From 45195efcc66e336976eb8d7dbe9a40fa67c4e8be Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 28 Jul 2019 17:41:27 -0500 Subject: [PATCH] um link page name instead of code --- app/models/concerns/has_attributes.rb | 2 +- app/views/documents/edit.html.erb | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/has_attributes.rb b/app/models/concerns/has_attributes.rb index 46dac36b..45a0a567 100644 --- a/app/models/concerns/has_attributes.rb +++ b/app/models/concerns/has_attributes.rb @@ -37,7 +37,7 @@ module HasAttributes # Always include the flatfile categories (but create AR versions if they don't exist) categories = YAML.load_file(Rails.root.join('config', 'attributes', "#{content_name}.yml")).map do |category_name, details| - category = AttributeCategory.with_deleted.find_or_initialize_by( + category = AttributeCategory.with_deleted.find_or_initialize_by( # i think we can do resets by just deleting all and removing with_deleted here entity_type: self.content_name, name: category_name.to_s, user: user diff --git a/app/views/documents/edit.html.erb b/app/views/documents/edit.html.erb index 0e0ec2de..aac189ac 100644 --- a/app/views/documents/edit.html.erb +++ b/app/views/documents/edit.html.erb @@ -21,6 +21,7 @@
<%= content_for :javascript do %> + // todo move this to global js that just triggers on any page with a .js-can-mention-pages $(document).ready(function(){ // Page @mentions var tribute = new Tribute({ @@ -30,7 +31,8 @@ <% collection.each do |page_name, page_id| %> { key: "<%= page_name.gsub('"', "\"").gsub("\n", " ").gsub("\r", " ").strip %>", - value: '[[<%= class_name %>-<%= page_id %>]]', + class: '<%= class_name %>', + id: <%= page_id %>, color: '<%= linkable_class.color %>', icon: '<%= linkable_class.icon %>' }, @@ -39,10 +41,14 @@ ], selectTemplate: function (item) { // We're overriding the default here so we don't prepend a @ - return '' + item.original.value + ''; + return '' + + item.original.key + + ''; }, menuItemTemplate: function (item) { - return '' + item.original.icon + '' + item.string; + return '' + item.original.icon + '' + item.string; }, spaceSelectsMatch: false });