fatfreecrm/fat_free_crm

View on GitHub
app/views/accounts/create.js.haml

Summary

Maintainability
Test Coverage
- entity_name = controller.controller_name.singularize.underscore #account
- @entity = instance_variable_get("@#{entity_name}")
- create_id = "create_#{entity_name}" # create_account

- if @entity.valid?
  $('##{create_id}_arrow').html(crm.COLLAPSED);
  $('##{create_id}_title').html('#{ j t(entity_name.pluralize) }');
  $('##{create_id}').slideUp(250);
  $('##{entity_name.pluralize}').prepend('#{ j render(partial: entity_name, collection: [ @entity ]) }');
  $('##{dom_id(@entity)}').effect("highlight", { duration:1500 });
  = refresh_sidebar(:index)
  $('#paginate').html('#{ j render(partial: "shared/paginate_with_per_page") }');
  crm.flick('empty', 'remove');
- else
  $('##{create_id}').html('#{ j render(partial: "new") }');
  $('#new_#{entity_name} input[type!=hidden]').first().focus();