created traits and front end for editing traits
This commit is contained in:
@@ -16,6 +16,7 @@ gem 'coffee-rails', '~> 4.1.0'
|
||||
|
||||
# Use jquery as the JavaScript library
|
||||
gem 'jquery-rails'
|
||||
gem 'jquery-ui-rails'
|
||||
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
||||
gem 'turbolinks'
|
||||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
||||
|
||||
@@ -79,6 +79,8 @@ GEM
|
||||
rails-dom-testing (~> 1.0)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
jquery-ui-rails (5.0.3)
|
||||
railties (>= 3.2.16)
|
||||
json (1.8.2)
|
||||
loofah (2.0.1)
|
||||
nokogiri (>= 1.5.9)
|
||||
@@ -174,6 +176,7 @@ DEPENDENCIES
|
||||
coffee-rails (~> 4.1.0)
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
jquery-ui-rails
|
||||
pg
|
||||
puma
|
||||
rails (= 4.2.0)
|
||||
|
||||
BIN
back-office/app/assets/images/.DS_Store
vendored
Normal file
BIN
back-office/app/assets/images/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -12,6 +12,7 @@
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require jquery-ui
|
||||
//= require turbolinks
|
||||
//= require active_scaffold
|
||||
//= require cloudinary
|
||||
|
||||
6302
back-office/app/assets/javascripts/jsoneditor.js
Normal file
6302
back-office/app/assets/javascripts/jsoneditor.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,5 +12,7 @@
|
||||
*
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*= require jquery-ui
|
||||
*= require active_scaffold
|
||||
*/
|
||||
|
||||
1
back-office/app/assets/stylesheets/jsoneditor.min.css
vendored
Normal file
1
back-office/app/assets/stylesheets/jsoneditor.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
back-office/app/views/items/_traits_form_column.html.erb
Normal file
6
back-office/app/views/items/_traits_form_column.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<label>Traits</label>
|
||||
<%= hidden_field :record, :traits %>
|
||||
<div id="json_save" style="display:none">Save JSON</div>
|
||||
<div id="json_editor"> </div>
|
||||
<div id="json_click" onclick="runJsonEditor('json_editor','record_traits','json_save','json_click')" > Click to view / edit </div>
|
||||
|
||||
@@ -16,7 +16,31 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<%= yield %>
|
||||
|
||||
<script type="text/javascript" >
|
||||
function runJsonEditor(id_of_editor_place, id_of_hidden_field, id_of_save_button, id_of_click_to_edit) {
|
||||
|
||||
|
||||
$("#" + id_of_click_to_edit).hide();
|
||||
$("#" + id_of_save_button).show();
|
||||
// create the editor
|
||||
var container = $("#" + id_of_editor_place).get(0);
|
||||
var editor = new JSONEditor(container);
|
||||
|
||||
var value = $("#" + id_of_hidden_field).val();
|
||||
if(value !== undefined && value !== "") {
|
||||
editor.set(JSON.parse(value));
|
||||
}
|
||||
|
||||
$("#" + id_of_save_button).click(function(e) {
|
||||
var field = $("#" + id_of_hidden_field);
|
||||
var json = editor.get();
|
||||
field.val(JSON.stringify(json));
|
||||
alert("JSON Edited. Save the record now !");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
BIN
back-office/public/img/jsoneditor-icons.png
Normal file
BIN
back-office/public/img/jsoneditor-icons.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,5 @@
|
||||
class AddTraitsToItem < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :items, :traits, :json
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150130041842) do
|
||||
ActiveRecord::Schema.define(version: 20150131061353) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -35,6 +35,7 @@ ActiveRecord::Schema.define(version: 20150130041842) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "tags"
|
||||
t.json "traits"
|
||||
end
|
||||
|
||||
create_table "media_types", force: :cascade do |t|
|
||||
|
||||
Reference in New Issue
Block a user