open-vault/website/source/assets/javascripts/lib/ember-data-1-0.min.js

4 lines
87 KiB
JavaScript
Raw Normal View History

(function(){"use strict";var e=Ember.get;var r=["description","fileName","lineNumber","message","name","number","stack"];function t(e){var t=Error.prototype.constructor.call(this,"The backend rejected the commit because it was invalid: "+Ember.inspect(e));this.errors=e;for(var i=0,n=r.length;i<n;i++){this[r[i]]=t[r[i]]}}t.prototype=Ember.create(Error.prototype);var i=Ember.Object.extend({find:null,findAll:null,findQuery:null,generateIdForRecord:null,serialize:function(r,t){var i=r._createSnapshot();return e(r,"store").serializerFor(i.typeKey).serialize(i,t)},createRecord:null,updateRecord:null,deleteRecord:null,coalesceFindRequests:true,groupRecordsForFindMany:function(e,r){return[r]}});var n=i;var a=Ember.get;var o=Ember.String.fmt;var s=Ember.EnumerableUtils.indexOf;var u=0;var c=n.extend({serializer:null,coalesceFindRequests:false,simulateRemoteResponse:true,latency:50,fixturesForType:function(e){if(e.FIXTURES){var r=Ember.A(e.FIXTURES);return r.map(function(e){var r=typeof e.id;if(r!=="number"&&r!=="string"){throw new Error(o("the id property must be defined as a number or string for fixture %@",[e]))}e.id=e.id+"";return e})}return null},queryFixtures:function(e,r,t){},updateFixtures:function(e,r){if(!e.FIXTURES){e.FIXTURES=[]}var t=e.FIXTURES;this.deleteLoadedFixture(e,r);t.push(r)},mockJSON:function(e,r,t){return e.serializerFor(t.typeKey).serialize(t,{includeId:true})},generateIdForRecord:function(e){return"fixture-"+u++},find:function(e,r,t,i){var n=this.fixturesForType(r);var a;if(n){a=Ember.A(n).findBy("id",t)}if(a){return this.simulateRemoteCall(function(){return a},this)}},findMany:function(e,r,t,i){var n=this.fixturesForType(r);if(n){n=n.filter(function(e){return s(t,e.id)!==-1})}if(n){return this.simulateRemoteCall(function(){return n},this)}},findAll:function(e,r){var t=this.fixturesForType(r);return this.simulateRemoteCall(function(){return t},this)},findQuery:function(e,r,t,i){var n=this.fixturesForType(r);n=this.queryFixtures(n,t,r);if(n){return this.simulateRemoteCall(function(){return n},this)}},createRecord:function(e,r,t){var i=this.mockJSON(e,r,t);this.updateFixtures(r,i);return this.simulateRemoteCall(function(){return i},this)},updateRecord:function(e,r,t){var i=this.mockJSON(e,r,t);this.updateFixtures(r,i);return this.simulateRemoteCall(function(){return i},this)},deleteRecord:function(e,r,t){this.deleteLoadedFixture(r,t);return this.simulateRemoteCall(function(){return null})},deleteLoadedFixture:function(e,r){var t=this.findExistingFixture(e,r);if(t){var i=s(e.FIXTURES,t);e.FIXTURES.splice(i,1);return true}},findExistingFixture:function(e,r){var t=this.fixturesForType(e);var i=r.id;return this.findFixtureById(t,i)},findFixtureById:function(e,r){return Ember.A(e).find(function(e){if(""+a(e,"id")===""+r){return true}else{return false}})},simulateRemoteCall:function(e,r){var t=this;return new Ember.RSVP.Promise(function(i){var n=Ember.copy(e.call(r),true);if(a(t,"simulateRemoteResponse")){Ember.run.later(function(){i(n)},a(t,"latency"))}else{Ember.run.schedule("actions",null,function(){i(n)})}},"DS: FixtureAdapter#simulateRemoteCall")}});var l=Ember.Map;var d=Ember.MapWithDefault;var h=l;var f=Ember.get;var p=Ember.Mixin.create({buildURL:function(e,r,t){var i=[];var n=f(this,"host");var a=this.urlPrefix();if(e){i.push(this.pathForType(e))}if(r&&!Ember.isArray(r)){i.push(encodeURIComponent(r))}if(a){i.unshift(a)}i=i.join("/");if(!n&&i){i="/"+i}return i},urlPrefix:function(e,r){var t=f(this,"host");var i=f(this,"namespace");var n=[];if(e){if(/^\/\//.test(e)){}else if(e.charAt(0)==="/"){if(t){e=e.slice(1);n.push(t)}}else if(!/^http(s)?:\/\//.test(e)){n.push(r)}}else{if(t){n.push(t)}if(i){n.push(i)}}if(e){n.push(e)}return n.join("/")},pathForType:function(e){var r=Ember.String.camelize(e);return Ember.String.pluralize(r)}});var m=Ember.get;var v=Ember.ArrayPolyfills.forEach;var y=i.extend(p,{defaultSerializer:"-rest",sortQueryParams:function(e){var r=Ember.keys(e);var t=r.length;if(t<2){return e}var i={};var n=r.sort();for(var a=0;a<t;a++){i[n[a]]=e[n[a]]}return i},coalesceFindRequests:false,find:fu
};ur.uncommitted.rollback=function(e){nr.uncommitted.rollback.apply(this,arguments);e.transitionTo("deleted.saved")};ur.uncommitted.pushedData=function(e){e.transitionTo("loaded.updated.uncommitted");e.triggerLater("didLoad")};ur.uncommitted.propertyWasReset=Ember.K;function lr(e){}cr.inFlight.unloadRecord=lr;cr.uncommitted.deleteRecord=function(e){e.transitionTo("deleted.uncommitted");e.disconnectRelationships()};var dr={isEmpty:false,isLoading:false,isLoaded:false,isDirty:false,isSaving:false,isDeleted:false,isNew:false,isValid:true,rolledBack:Ember.K,unloadRecord:function(e){e.clearRelationships();e.transitionTo("deleted.saved")},propertyWasReset:Ember.K,empty:{isEmpty:true,loadingData:function(e,r){e._loadingPromise=r;e.transitionTo("loading")},loadedData:function(e){e.transitionTo("loaded.created.uncommitted");e.triggerLater("ready")},pushedData:function(e){e.transitionTo("loaded.saved");e.triggerLater("didLoad");e.triggerLater("ready")}},loading:{isLoading:true,exit:function(e){e._loadingPromise=null},pushedData:function(e){e.transitionTo("loaded.saved");e.triggerLater("didLoad");e.triggerLater("ready");tr(e,"isError",false)},becameError:function(e){e.triggerLater("becameError",e)},notFound:function(e){e.transitionTo("empty")}},loaded:{initialState:"saved",isLoaded:true,loadingData:Ember.K,saved:{setup:function(e){var r=e._attributes;var t=Ember.keys(r).length>0;if(t){e.adapterDidDirty()}},didSetProperty:ir,pushedData:Ember.K,becomeDirty:function(e){e.transitionTo("updated.uncommitted")},willCommit:function(e){e.transitionTo("updated.inFlight")},reloadRecord:function(e,r){r(rr(e,"store").reloadRecord(e))},deleteRecord:function(e){e.transitionTo("deleted.uncommitted");e.disconnectRelationships()},unloadRecord:function(e){e.clearRelationships();e.transitionTo("deleted.saved")},didCommit:function(e){e.send("invokeLifecycleCallbacks",rr(e,"lastDirtyType"))},notFound:Ember.K},created:ur,updated:cr},deleted:{initialState:"uncommitted",dirtyType:"deleted",isDeleted:true,isLoaded:true,isDirty:true,setup:function(e){e.updateRecordArrays()},uncommitted:{willCommit:function(e){e.transitionTo("inFlight")},rollback:function(e){e.rollback();e.triggerLater("ready")},becomeDirty:Ember.K,deleteRecord:Ember.K,rolledBack:function(e){e.transitionTo("loaded.saved");e.triggerLater("ready")}},inFlight:{isSaving:true,unloadRecord:lr,willCommit:Ember.K,didCommit:function(e){e.transitionTo("saved");e.send("invokeLifecycleCallbacks")},becameError:function(e){e.transitionTo("uncommitted");e.triggerLater("becameError",e)},becameInvalid:function(e){e.transitionTo("invalid");e.triggerLater("becameInvalid",e)}},saved:{isDirty:false,setup:function(e){var r=rr(e,"store");r._dematerializeRecord(e)},invokeLifecycleCallbacks:function(e){e.triggerLater("didDelete",e);e.triggerLater("didCommit",e)},willCommit:Ember.K,didCommit:Ember.K},invalid:{isValid:false,didSetProperty:function(e,r){rr(e,"errors").remove(r.name);ir(e,r)},deleteRecord:Ember.K,becomeDirty:Ember.K,willCommit:Ember.K,rolledBack:function(e){rr(e,"errors").clear();e.transitionTo("loaded.saved");e.triggerLater("ready")},becameValid:function(e){e.transitionTo("uncommitted")}}},invokeLifecycleCallbacks:function(e,r){if(r==="created"){e.triggerLater("didCreate",e)}else{e.triggerLater("didUpdate",e)}e.triggerLater("didCommit",e)}};function hr(e,r,t){e=or(r?Ember.create(r):{},e);e.parentState=r;e.stateName=t;for(var i in e){if(!e.hasOwnProperty(i)||i==="parentState"||i==="stateName"){continue}if(typeof e[i]==="object"){e[i]=hr(e[i],e,t+"."+i)}}return e}dr=hr(dr,null,"root");var fr=dr;var pr=Ember.get;var mr=Ember.isEmpty;var vr=Ember.EnumerableUtils.map;var yr=Ember.Object.extend(Ember.Enumerable,Ember.Evented,{registerHandlers:function(e,r,t){this.on("becameInvalid",e,r);this.on("becameValid",e,t)},errorsByAttributeName:Ember.reduceComputed("content",{initialValue:function(){return d.create({defaultValue:function(){return Ember.A()}})},addedItem:function(e,r){e.get(r.attribute).pushObject(r);return e},removedItem:function(e,r){e.get(r.attribute).removeObject(r);return e}}),errorsFor:function(
container:this.container,store:this})}return e}),createRecord:function(e,r){var t=this.modelFor(e);var i=mt(r)||{};if(lt(i.id)){i.id=this._generateId(t,i)}i.id=gt(i.id);var n=this.buildRecord(t,i.id);n.loadedData();n.setProperties(i);return n},_generateId:function(e,r){var t=this.adapterFor(e);if(t&&t.generateIdForRecord){return t.generateIdForRecord(this,e,r)}return null},deleteRecord:function(e){e.deleteRecord()},unloadRecord:function(e){e.unloadRecord()},find:function(e,r,t){if(arguments.length===1){return this.findAll(e)}if(Ember.typeOf(r)==="object"){return this.findQuery(e,r)}return this.findById(e,gt(r),t)},fetchById:function(e,r,t){if(this.hasRecordForId(e,r)){return this.getById(e,r).reload()}else{return this.find(e,r,t)}},fetchAll:function(e){e=this.modelFor(e);return this._fetchAll(e,this.all(e))},fetch:function(e,r,t){return this.fetchById(e,r,t)},findById:function(e,r,t){var i=this.modelFor(e);var n=this.recordForId(i,r);return this._findByRecord(n,t)},_findByRecord:function(e,r){var t;if(r){e._preloadData(r)}if(st(e,"isEmpty")){t=this.scheduleFetch(e)}else if(st(e,"isLoading")){t=e._loadingPromise}return ge(t||e,"DS: Store#findByRecord "+e.typeKey+" with id: "+st(e,"id"))},findByIds:function(e,r){var t=this;return Re(Ember.RSVP.all(ft(r,function(r){return t.findById(e,r)})).then(Ember.A,null,"DS: Store#findByIds of "+e+" complete"))},fetchRecord:function(e){var r=e.constructor;var t=st(e,"id");var i=this.adapterFor(r);var n=xe(i,this,r,t,e);return n},scheduleFetchMany:function(e){return pt.all(ft(e,this.scheduleFetch,this))},scheduleFetch:function(e){var r=e.constructor;if(lt(e)){return null}if(e._loadingPromise){return e._loadingPromise}var t=Ember.RSVP.defer("Fetching "+r+"with id: "+e.get("id"));var i={record:e,resolver:t};var n=t.promise;e.loadingData(n);if(!this._pendingFetch.get(r)){this._pendingFetch.set(r,[i])}else{this._pendingFetch.get(r).push(i)}Ember.run.scheduleOnce("afterRender",this,this.flushAllPendingFetches);return n},flushAllPendingFetches:function(){if(this.isDestroyed||this.isDestroying){return}this._pendingFetch.forEach(this._flushPendingFetchForType,this);this._pendingFetch=l.create()},_flushPendingFetchForType:function(e,r){var t=this;var i=t.adapterFor(r);var n=!!i.findMany&&i.coalesceFindRequests;var a=Ember.A(e).mapBy("record");function o(e){e.resolver.resolve(t.fetchRecord(e.record))}function s(r){dt(r,function(r){var t=Ember.A(e).findBy("record",r);if(t){var i=t.resolver;i.resolve(r)}});return r}function u(e){return function r(t){t=Ember.A(t);var i=e.reject(function(e){return t.contains(e)});if(i.length){}l(i)}}function c(e){return function(r){l(e,r)}}function l(r,t){dt(r,function(r){var i=Ember.A(e).findBy("record",r);if(i){var n=i.resolver;n.reject(t)}})}if(e.length===1){o(e[0])}else if(n){var d=Ember.A(a).invoke("_createSnapshot");var h=i.groupRecordsForFindMany(this,d);dt(h,function(n){var a=Ember.A(n).mapBy("record");var l=Ember.A(a);var d=l.mapBy("id");if(d.length>1){we(i,t,r,d,l).then(s).then(u(l)).then(null,c(l))}else if(d.length===1){var h=Ember.A(e).findBy("record",a[0]);o(h)}else{}})}else{dt(e,o)}},getById:function(e,r){if(this.hasRecordForId(e,r)){return this.recordForId(e,r)}else{return null}},reloadRecord:function(e){var r=e.constructor;var t=this.adapterFor(r);var i=st(e,"id");return this.scheduleFetch(e)},hasRecordForId:function(e,r){var t=this.modelFor(e);var i=gt(r);var n=this.typeMapFor(t).idToRecord[i];return!!n&&st(n,"isLoaded")},recordForId:function(e,r){var t=this.modelFor(e);var i=gt(r);var n=this.typeMapFor(t).idToRecord;var a=n[i];if(!a||!n[i]){a=this.buildRecord(t,i)}return a},findMany:function(e){var r=this;return pt.all(ft(e,function(e){return r._findByRecord(e)}))},findHasMany:function(e,r,t){var i=this.adapterFor(e.constructor);return De(i,this,e,r,t)},findBelongsTo:function(e,r,t){var i=this.adapterFor(e.constructor);return Pe(i,this,e,r,t)},findQuery:function(e,r){var t=this.modelFor(e);var i=this.recordArrayManager.createAdapterPopulatedRecordArray(t,r);var n=this.adapterFor(t);return Re(Ie(n,this,t,r,i))},findAll:function(e){return this.fetchA