Migrate content types to the new attribute system

This commit is contained in:
Andrew Brown 2016-11-01 21:51:57 +01:00
parent d107512438
commit a896c3c5ae
21 changed files with 484 additions and 203 deletions

View File

@ -11,7 +11,7 @@ class CreaturesController < ContentController
materials preferred_habitat sounds strengths weaknesses spoils aggressiveness
attack_method defense_method maximum_speed food_sources
migratory_patterns reproduction herd_patterns
similar_animals symbolisms privacy
similar_animals symbolisms privacy notes private_notes
) + [
wildlifeships_attributes: [:id, :habitat_id, :_destroy],
]

View File

@ -10,7 +10,7 @@ class GroupsController < ContentController
name description other_names universe_id
organization_structure
motivation goal obstacles risks
inventory
inventory notes private_notes
) + [
group_leaderships_attributes: [:id, :leader_id, :_destroy],
supergroupships_attributes: [:id, :supergroup_id, :_destroy],

View File

@ -8,7 +8,7 @@ class RacesController < ContentController
def content_param_list
%i(
name description other_names universe_id
body_shape skin_colors height weight notable_features variance_clothing
body_shape skin_colors height weight notable_features variance clothing
strengths weaknesses
traditions beliefs governments technologies occupations economics favorite_foods
notable_events

View File

@ -14,6 +14,7 @@ class Creature < ActiveRecord::Base
belongs_to :universe
include HasAttributes
include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern
@ -31,32 +32,7 @@ class Creature < ActiveRecord::Base
'pets'
end
def self.attribute_categories
{
overview: {
icon: 'info',
attributes: %w(name description type_of other_names universe_id)
},
looks: {
icon: 'pets',
attributes: %w(color shape size notable_features materials)
},
traits: {
icon: 'fingerprint',
attributes: %w(aggressiveness attack_method defense_method maximum_speed strengths weaknesses sounds spoils)
},
habitat: {
icon: 'location_on',
attributes: %w(preferred_habitat habitats food_sources migratory_patterns reproduction herd_patterns)
},
comparisons: {
icon: 'call_split',
attributes: %w(similar_animals symbolisms)
},
notes: {
icon: 'edit',
attributes: %w(notes private_notes)
}
}
def self.content_name
'creature'
end
end

View File

@ -6,6 +6,7 @@ class Group < ActiveRecord::Base
belongs_to :universe
include HasAttributes
include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern
@ -41,36 +42,7 @@ class Group < ActiveRecord::Base
'wc'
end
def self.attribute_categories
{
overview: {
icon: 'info',
attributes: %w(name description other_names universe_id)
},
hierarchy: {
icon: 'call_split',
attributes: %w(organization_structure leaders supergroups subgroups sistergroups)
},
location: {
icon: 'location_on',
attributes: %w(headquarters offices)
},
purpose: {
icon: 'business',
attributes: %w(motivation goal obstacles risks)
},
politics: {
icon: 'thumbs_up_down',
attributes: %w(allies enemies rivals clients)
},
inventory: {
icon: 'shopping_cart',
attributes: %w(inventory equipment key_items suppliers)
},
notes: {
icon: 'edit',
attributes: %w(notes private_notes)
}
}
def self.content_name
'group'
end
end

View File

@ -6,6 +6,7 @@ class Language < ActiveRecord::Base
belongs_to :universe
include HasAttributes
include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern
@ -25,40 +26,7 @@ class Language < ActiveRecord::Base
'forum'
end
def self.attribute_categories
{
overview: {
icon: 'info',
attributes: %w(name other_names universe_id)
},
info: {
icon: 'forum',
attributes: %w(history typology dialectical_information register)
},
phonology: {
icon: 'speaker_notes',
attributes: %w(phonology)
},
grammar: {
icon: 'list',
attributes: %w(grammar)
},
entities: {
icon: 'settings_input_component',
attributes: %w(numbers quantifiers)
},
# lexicon: {
# icon: 'info',
# attributes: %w()
# },
# spoken_by: {
# icon: 'info',
# attributes: %w()
# },
notes: {
icon: 'edit',
attributes: %w(notes private_notes)
}
}
def self.content_name
'language'
end
end

View File

@ -6,6 +6,7 @@ class Magic < ActiveRecord::Base
belongs_to :universe
include HasAttributes
include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern
@ -23,32 +24,7 @@ class Magic < ActiveRecord::Base
'flash_on'
end
def self.attribute_categories
{
overview: {
icon: 'info',
attributes: %w(name description type_of universe_id)
},
appearance: {
icon: 'flash_on',
attributes: %w(visuals effects)
},
effects: {
icon: 'flare',
attributes: %w(positive_effects negative_effects neutral_effects)
},
alignment: {
icon: 'polymer',
attributes: %w(element deities)
},
requirements: {
icon: 'lock',
attributes: %w(resource_costs materials skills_required limitations)
},
notes: {
icon: 'edit',
attributes: %w(notes private_notes)
}
}
def self.content_name
'magic'
end
end

View File

@ -12,6 +12,7 @@ class Race < ActiveRecord::Base
belongs_to :universe
include HasAttributes
include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern
@ -29,32 +30,7 @@ class Race < ActiveRecord::Base
'face'
end
def self.attribute_categories
{
overview: {
icon: 'info',
attributes: %w(name description other_names universe_id)
},
looks: {
icon: 'face',
attributes: %w(body_shape skin_colors height weight notable_features variance clothing)
},
traits: {
icon: 'fingerprint',
attributes: %w(strengths weaknesses)
},
culture: {
icon: 'groups',
attributes: %w(famous_figures traditions beliefs governments technologies occupations economics favorite_foods)
},
history: {
icon: 'import_contacts',
attributes: %w(notable_events)
},
notes: {
icon: 'edit',
attributes: %w(notes private_notes)
}
}
def self.content_name
'race'
end
end

View File

@ -6,6 +6,7 @@ class Religion < ActiveRecord::Base
belongs_to :universe
include HasAttributes
include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern
@ -33,32 +34,7 @@ class Religion < ActiveRecord::Base
'brightness_7'
end
def self.attribute_categories
{
overview: {
icon: 'info',
attributes: %w(name description other_names universe_id)
},
history: {
icon: 'import_contacts',
attributes: %w(origin_story notable_figures artifacts)
},
beliefs: {
icon: 'forum',
attributes: %w(deities teachings prophecies places_of_worship worship_services obligations paradise)
},
traditions: {
icon: 'account_balance',
attributes: %w(initiation rituals holidays)
},
spread: {
icon: 'location_on',
attributes: %w(practicing_locations races)
},
notes: {
icon: 'edit',
attributes: %w(notes private_notes)
}
}
def self.content_name
'religion'
end
end

View File

@ -6,6 +6,7 @@ class Scene < ActiveRecord::Base
belongs_to :universe
include HasAttributes
include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern
@ -29,24 +30,7 @@ class Scene < ActiveRecord::Base
'local_movies'
end
def self.attribute_categories
{
overview: {
icon: 'info',
attributes: %w(name summary universe_id)
},
members: {
icon: 'face',
attributes: %w(scene_characters scene_locations scene_items)
},
action: {
icon: 'gesture',
attributes: %w(cause description results)
},
notes: {
icon: 'edit',
attributes: %w(notes private_notes)
}
}
def self.content_name
'scene'
end
end

View File

@ -15,6 +15,11 @@
<div class="row">
<%= f.text_area :label, class: "materialize-textarea", placeholder: "Field Name" %>
</div>
<p class="row">
Please save any changes before adding a field. It will refresh the page and any changes in your form
will be lost.
</p>
</div>
<div class="modal-footer">

View File

@ -58,12 +58,12 @@
<%= t("content_descriptions.#{content_type}") %>
</p>
<div class="center hide-on-small-only">
<% button_text = content_list.any? ? "Create another #{content_type}" : "Create your first #{content_type}" %>
<% button_text = content_list.any? ? "Create another #{content_type}" : "Create one" %>
<%= link_to button_text, new_polymorphic_path(content_type), class: "btn #{content_type_class.color}" if current_user %>
</div>
</div>
<div class="center hide-on-med-and-up">
<% button_text = content_list.any? ? "Create another #{content_type}" : "Create your first #{content_type}" %>
<% button_text = content_list.any? ? "Create another #{content_type}" : "Create one" %>
<%= link_to button_text, new_polymorphic_path(content_type), class: "btn #{content_type_class.color}" if current_user %>
</div>
</div>

View File

@ -14,10 +14,10 @@
%>
<div class="input-field content-field">
<%= f.label attribute, I18n.translate( # todo use field.name here instead of attribute?
"attributes.#{class_name}.#{attribute}",
<%= f.label field.name, I18n.translate(
"attributes.#{f.object.class.name}.#{field.name}",
scope: :activerecord,
default: attribute.humanize.capitalize
default: field.label.humanize.capitalize
) %>
<%
placeholder = I18n.translate "attributes.#{content_name}.#{field.name}",

View File

@ -1,5 +1,6 @@
<%
content_type_class = @content.build.class
content_type = content_type_class.name.downcase
%>
<% content_for :sidebar_top do %>
@ -43,7 +44,7 @@
</small>
<% end %>
</h4>
<%= render partial: 'content/list/list', locals: { content_list: @content.content_name, show_add_another_form: true } %>
<%= render partial: 'content/list/list', locals: { content_list: @content, show_add_another_form: true } %>
<% elsif @content.empty? %>
@ -55,7 +56,7 @@
</i>
</h1>
<p>
<%= t("content_descriptions.#{content_type_class.name.downcase}") %>
<%= t("content_descriptions.#{content_type}") %>
</p>
<%= link_to "Create your first #{@content.content_name.humanize.downcase}", new_polymorphic_path(@content.build), class: "btn #{content_type_class.color}" %>
</div>

View File

@ -0,0 +1,79 @@
:overview:
:label: Overview
:icon: info
:attributes:
- :name: name
:label: Name
- :name: description
:label: Description
- :name: type_of
:label: Type of creature
- :name: universe_id
:label: Universe
:looks:
:label: Looks
:icon: pets
:attributes:
- :name: color
:label: Color
- :name: shape
:label: Shape
- :name: size
:label: Size
- :name: notable_features
:label: Notable features
- :name: materials
:label: Materials
:traits:
:label: Traits
:icon: fingerprint
:attributes:
- :name: aggressiveness
:label: Aggressiveness
- :name: attack_method
:label: Method of attack
- :name: defense_method
:label: Methods of defense
- :name: maximum_speed
:label: Maximum speed
- :name: strengths
:label: Strengths
- :name: weaknesses
:label: Weaknesses
- :name: sounds
:label: Sounds
- :name: spoils
:label: Spoils
:habitat:
:label: Habitat
:icon: location_on
:attributes:
- :name: preferred_habitat
:label: Preferred habitat
- :name: habitats
:label: Habitats
- :name: food_sources
:label: Food sources
- :name: migratory_patterns
:label: Migratory patterns
- :name: reproduction
:label: Reproductive patterns
- :name: herd_patterns
:label: Herding patterns
:comparisons:
:label: Comparisons
:icon: call_split
:attributes:
- :name: similar_animals
:label: Similar animals
- :name: symbolisms
:label: Symbolisms
:notes:
:label: Notes
:icon: edit
:attributes:
- :name: notes
:label: Notes
- :name: private_notes
:label: Private notes
:description: Private notes are <em>always</em> visible to only you, even if content is made public and shared.

View File

@ -0,0 +1,79 @@
:overview:
:label: Overview
:icon: info
:attributes:
- :name: name
:label: Name
- :name: description
:label: Description
- :name: other_names
:label: Other names
- :name: universe_id
:label: Universe
:hierarchy:
:label: Hierarchy
:icon: call_split
:attributes:
- :name: organization_structure
:label: Organization structure
- :name: leaders
:label: Leaders
- :name: supergroups
:label: Supergroups
- :name: subgroups
:label: Subgroups
- :name: sistergroups
:label: Sistergroups
:location:
:label: Location
:icon: location_on
:attributes:
- :name: headquarters
:label: Headquarters
- :name: offices
:label: Offices
:purpose:
:label: Purpose
:icon: business
:attributes:
- :name: motivation
:label: Motivations
- :name: goal
:label: Goals
- :name: obstacles
:label: Obstacles
- :name: risks
:label: Risks
:politics:
:label: Politics
:icon: thumbs_up_down
:attributes:
- :name: allies
:label: Allies
- :name: enemies
:label: Enemies
- :name: rivals
:label: Rivals
- :name: clients
:label: Clients
:inventory:
:label: Inventory
:icon: shopping_cart
:attributes:
- :name: inventory
:label: Inventory
- :name: equipment
:label: Equipment
- :name: key_items
:label: Key items
- :name: suppliers
:label: Suppliers
:notes:
:label: Notes
:icon: edit
:attributes:
- :name: notes
:label: Notes
- :name: private_notes
:label: Private notes
:description: Private notes are <em>always</em> visible to only you, even if content is made public and shared.

View File

@ -0,0 +1,51 @@
:overview:
:label: Overview
:icon: info
:attributes:
- :name: name
:label: Name
- :name: other_names
:label: Other names
- :name: universe_id
:label: Universe
:info:
:label: Info
:icon: forum
:attributes:
- :name: history
:label: History
- :name: typology
:label: Typology
- :name: dialectical_information
:label: Dialectical information
- :name: register
:label: Register
:phonology:
:label: Phonology
:icon: speaker_notes
:attributes:
- :name: phonology
:label: Phonology
:grammar:
:label: Grammar
:icon: list
:attributes:
- :name: grammar
:label: Grammar
:entities:
:label: Entities
:icon: settings_input_component
:attributes:
- :name: numbers
:label: Numbers
- :name: quantifiers
:label: Quantifiers
:notes:
:label: Notes
:icon: edit
:attributes:
- :name: notes
:label: Notes
- :name: private_notes
:label: Private notes
:description: Private notes are <em>always</em> visible to only you, even if content is made public and shared.

View File

@ -0,0 +1,59 @@
:overview:
:label: Overview
:icon: info
:attributes:
- :name: name
:label: Name
- :name: description
:label: Description
- :name: type_of
:label: Type of magic
- :name: universe_id
:label: Universe
:appearance:
:label: Appearance
:icon: flash_on
:attributes:
- :name: visuals
:label: Visuals
- :name: effects
:label: Effects
:effects:
:label: Effects
:icon: flare
:attributes:
- :name: positive_effects
:label: Positive effects
- :name: neutral_effects
:label: Neutral effects
- :name: negative_effects
:label: Negative effects
:alignment:
:label: Alignment
:icon: polymer
:attributes:
- :name: element
:label: Element
- :name: deities
:label: Deities
:requirements:
:label: Requirements
:icon: lock
:attributes:
- :name: resource_costs
:label: Resource costs
- :name: materials
:label: Materials required
- :name: skills_required
:label: Skills required
- :name: limitations
:label: Limitations
:notes:
:label: Notes
:icon: edit
:attributes:
- :name: notes
:label: Notes
- :name: private_notes
:label: Private notes
:description: Private notes are <em>always</em> visible to only you, even if content is made public and shared.

View File

@ -0,0 +1,73 @@
:overview:
:label: Overview
:icon: info
:attributes:
- :name: name
:label: Name
- :name: description
:label: Description
- :name: other_names
:label: Other names
- :name: universe_id
:label: Universe
:looks:
:label: Looks
:icon: face
:attributes:
- :name: body_shape
:label: Body shape
- :name: skin_colors
:label: Skin colors
- :name: height
:label: General height
- :name: weight
:label: General weight
- :name: notable_features
:label: Notable features
- :name: variance
:label: Physical variance
- :name: clothing
:label: Typical clothing
:traits:
:label: Traits
:icon: fingerprint
:attributes:
- :name: strengths
:label: Strengths
- :name: weaknesses
:label: Weaknesses
:culture:
:label: Culture
:icon: groups
:attributes:
- :name: famous_figures
:label: Famous figures
- :name: traditions
:label: Traditions
- :name: beliefs
:label: Beliefs
- :name: governments
:label: Governments
- :name: technologies
:label: Technologies
- :name: occupations
:label: Occupations
- :name: economics
:label: Economics
- :name: favorite_foods
:label: Favorite foods
:history:
:label: History
:icon: import_contacts
:attributes:
- :name: notable_events
:label: Notable events
:notes:
:label: Notes
:icon: edit
:attributes:
- :name: notes
:label: Notes
- :name: private_notes
:label: Private notes
:description: Private notes are <em>always</em> visible to only you, even if content is made public and shared.

View File

@ -0,0 +1,67 @@
:overview:
:label: Overview
:icon: info
:attributes:
- :name: name
:label: Name
- :name: description
:label: Description
- :name: other_names
:label: Other names
- :name: universe_id
:label: Universe
:history:
:label: History
:icon: import_contacts
:attributes:
- :name: origin_story
:label: Origin story
- :name: notable_figures
:label: Notable figures
- :name: artifacts
:label: Artifacts
:beliefs:
:label: Beliefs
:icon: forum
:attributes:
- :name: deities
:label: Deities
- :name: teachings
:label: Teachings
- :name: prophecies
:label: Prophecies
- :name: places_of_worship
:label: Places of worship
- :name: worship_services
:label: Worship services
- :name: obligations
:label: Obligations
- :name: paradise
:label: Vision of paradise
:traditions:
:label: Traditions
:icon: account_balance
:attributes:
- :name: initiation
:label: Initiation process
- :name: rituals
:label: Rituals
- :name: holidays
:label: Holidays
:spread:
:label: Spread
:icon: location_on
:attributes:
- :name: practicing_locations
:label: Practicing locations
- :name: races
:label: Practicing races
:notes:
:label: Notes
:icon: edit
:attributes:
- :name: notes
:label: Notes
- :name: private_notes
:label: Private notes
:description: Private notes are <em>always</em> visible to only you, even if content is made public and shared.

View File

@ -0,0 +1,39 @@
:overview:
:label: Overview
:icon: info
:attributes:
- :name: name
:label: Name
- :name: summary
:label: Summary
- :name: universe_id
:label: Universe
:looks:
:label: members
:icon: face
:attributes:
- :name: scene_characters
:label: Characters in scene
- :name: scene_locations
:label: Locations in scene
- :name: scene_items
:label: Items in scene
:action:
:label: Action
:icon: gesture
:attributes:
- :name: cause
:label: What caused this?
- :name: description
:label: Description
- :name: results
:label: Results
:notes:
:label: Notes
:icon: edit
:attributes:
- :name: notes
:label: Notes
- :name: private_notes
:label: Private notes
:description: Private notes are <em>always</em> visible to only you, even if content is made public and shared.