katalyst/koi — pull request #71 by alexkg (2013-06-04 07:02:34+00:00)
Title: Navigator and Settings updates used in SAP-V2

In order of "Files Changed":

### app/assets/javascripts/koi/application.js

Refactored the JavaScript to make it easier to read.

Added code to handle targetable tabs (when the page is loaded, the tab is selected if the corresponding hash is present):

https://github.com/katalyst/koi/blob/51002c08ead9f39ab1c452c475231a9a5e5251f7/app/assets/javascripts/koi/application.js#L102

Added code to handle dynamic removal of settings fields (by setting the corresponding `_destroy` field to `true`.

### app/assets/javascripts/koi/common.js

Changed the reference to jquery-ui to jquery.ui.all (also in Gemfile).

### app/assets/javascripts/koi/application.scss

Fixed styling for tabs (display:none was preventing proper initialisation of CKEDITOR on hidden tabs).

Also cleaned up settings styling for the admin view.

### app/controllers/koi/settings_controller.rb

New bulk_create_or_update method to allow e.g. collection settings to be updated (since we can't use normal rails association methods).

Also handles redirection after settings update (which must go back to whence it came).

### app/helpers/koi/navigation_helper.rb

Added mobile checking to the Navigation helper, and cleaned up NavigationHelper code.

### app/helpers/koi/navigation_helper/navigator.rb

Adapted to accomodate cascadable settings.

Better handling of `:if` and `:unless` filters, and mobile checking.

Tree navigation methods now have `visible_` counterparts, which restricts results based on `is_mobile?`, `:if` and `:unless`.

More robust highlighting routine.

### app/models/asset.rb

Pointless but pleasurable refactoring.

### app/models/nav_item.rb

Added settings possible for NavItems (although not currently implemented in the admin views).

### app/models/setting.rb

Changed the order of form fields for settings to make it clearer.

### app/models/translation.rb

Removing invalid images from the Setting/Translation so they don't need to be validated.

Destroying the settings record if `_destroy` is set (by dynamic removal).

Added more default values.

Refactored the scopes a bit.

### app/views/koi/admin_crud/_form.html.erb

Made settings part of with the new/edit form (accomodated by the `settings_attributes=` method defined in `has_settings`.

### app/views/koi/admin_crud/_form_field_dynamic.html.erb

Copied verbatim the `translations` folder so it can be used by general crud town.

### app/views/koi/admin_crud/_form_field_nested.html.erb

Nicer styling for nested fields labels.

### app/views/koi/admin_crud/_form_field_select.html.erb

Fix for erroneous global `resource_class` reference (should correspond to the object in the form).

### app/views/koi/admin_crud/_index_field_boolean.csv.erb

More robust boolean field check required for BSA-V2.

### app/views/koi/admin_crud/_index_field_boolean.html.erb

More robust boolean field check required for BSA-V2.

### app/views/koi/admin_crud/edit.html.erb

Refactoring to allow settings to be part of the actual form.

### app/views/koi/admin_crud/index.html.erb

Accomodate settings for collections in a hackish but working fashion.

### app/views/koi/settings/_modal_setting.html.erb

Force page reload when updating modal settings.

### app/views/koi/settings/_settings_fields.html.erb

The new form for settings fields.

### app/views/koi/translations/_form_fields.html.erb

Hackery to allow this partial to be called recursively.

### app/views/koi/translations/index.html.erb

Updating the original settings view to work with the new way of handling settings.

### config/routes.rb

New route to allow bulk update of settings (which is the only way to update settings that aren't on a resource).

### koi.gemspec

Fix for jquery dependencies.

### lib/has_crud/has_crud/action_controller/crud_additions.rb

Defined a `settings_hash` which gloms together the resource settings as a Hash. Defaults to collection settings if available.

### lib/has_crud/has_crud/action_controller/crud_admin_additions.rb

Placeholder for being able to set settings directly in an instance action.

### lib/has_navigation/has_navigation/has_navigation.rb

Fixed a problem in navigation where the front-end routes (like `edit_page_path`) weren't defined. Tries to resolve as an `:admin` path before trying to resolve it as a `Koi::Engine` path.

### lib/has_settings/has_settings/shared_methods.rb

Added `settings_hash` method to return settings as a hash for this object.

Added `settings_attributes=` to allow update of settings in the bulk assignment kind of way.