Sha256: b32cd94990253c3f764accd7bc1ca2886295e50c95c0c78e7138592dd174eaf1
Contents?: true
Size: 1.48 KB
Versions: 7
Compression:
Stored size: 1.48 KB
Contents
class RailsUpdate constructor: ($injector,factoryName,scope,controllers,model,override)-> @injector = $injector @factoryName = factoryName @scope = scope @modelName = (override || model).split('.')[0] @atomName = (override || model).split('.')[1] @override = !!override @factory = @injector.get(@factoryName(@modelName)) @ngModelCtrl = controllers.shift() @controllers = controllers return @ equiv: (left,right) -> return true if left == right return true if (!!left && !!right) == false false update: (value) -> @value = if @override then scope.$eval(@atomName) else value object = {id: @scope.$eval(@modelName).id} object[@modelName] = {} object[@modelName][@atomName] = value unless @scope[@modelName].currently_updating @scope[@modelName].currently_updating = true up = @ @factory.update object, (returnData) -> up.scope[up.modelName].currently_updating = false unless up.equiv(up.ngModelCtrl.$viewValue,returnData[up.atomName]) up.ngModelCtrl.$setModelValue = returnData[up.atomName] up.ngModelCtrl.$render() for controller in up.controllers controller.evaluate(returnData) if !!controller angular.module 'RailsUpdater', ['Factories', 'FactoryName'] .factory 'RailsUpdater', ($injector,factoryName) -> new: (scope,controllers,model,override)-> return new RailsUpdate($injector,factoryName,scope,controllers,model,override)
Version data entries
7 entries across 7 versions & 1 rubygems