breeze / breeze.js.labs Goto Github PK
View Code? Open in Web Editor NEWOFFICIAL Breeze.js Labs package of extensions and utilities for Breeze.js client apps.
License: MIT License
OFFICIAL Breeze.js Labs package of extensions and utilities for Breeze.js client apps.
License: MIT License
While CORS support added to the platform is a huge improvement, still need to be able to handle cross domain calls in SharePoint 2013 (because CORS isn't available on-prem nor will it work in apps / solutions that don't use OAuth tokens for authentication).
When using bootstrap input groups, the z-append-to allows a query selector to identify an element to append the z-decorator to.
However, within an ng-repeat it is a pain to generate unique ids to append to. The accompanying pull request will append to an element in exactly the same way if a single DOM element matches the querySelector, but if more than one element matches, it will find the first matching ancestor of the input/tetxarea/select element being validated. In this way the z-append-to directive now works with class and element selectors.
If saveChanges is called very quickly with a complex data model it sometimes throws the error "Concurrent saves not allowed." An entity from the previous saveChanges call is included in the next call to saveChanges with an entityAspect of isBeingSaved = true. It appears that there is some kind of race condition where the previous save promise resolves before isBeingSaved is set to false.
(Using Breeze 1.5.0, Angular 1.0.8, breeze.savequeuing 0.9, breeze.angular 1.1)
I have an error with "AngularJS v1.3.0-beta.13" and config zDirectivesConfigProvider in this lines:
var app = angular.module('app', ['breeze.directives']);
app.config('zDirectivesConfigProvider', function (cfg) {
cfg.zValidateTemplate = '' +
'Error! %error%';
});
The next error:
Error: [$injector:modulerr] Failed to instantiate module app due to: [ng:areq] Argument 'fn' is not a function, got string http://errors.angularjs.org/1.3.0-beta.13/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20string minErr/<@http://localhost:11881/scripts/angular.js:78 assertArg@http://localhost:11881/scripts/angular.js:1581 assertArgFn@http://localhost:11881/scripts/angular.js:1592 annotate@http://localhost:11881/scripts/angular.js:3356 invoke@http://localhost:11881/scripts/angular.js:4022 runInvokeQueue@http://localhost:11881/scripts/angular.js:3950 createInjector/loadModules/<@http://localhost:11881/scripts/angular.js:3959 forEach@http://localhost:11881/scripts/angular.js:324 loadModules@http://localhost:11881/scripts/angular.js:3940 createInjector@http://localhost:11881/scripts/angular.js:3880 bootstrap/doBootstrap@http://localhost:11881/scripts/angular.js:1504 bootstrap@http://localhost:11881/scripts/angular.js:1519 angularInit@http://localhost:11881/scripts/angular.js:1431 @http://localhost:11881/scripts/angular.js:22856 jQuery.Callbacks/fire@http://localhost:11881/scripts/jquery-2.1.1.js:3073 jQuery.Callbacks/self.fireWith@http://localhost:11881/scripts/jquery-2.1.1.js:3185 .ready@http://localhost:11881/scripts/jquery-2.1.1.js:3391 completed@http://localhost:11881/scripts/jquery-2.1.1.js:3407 http://errors.angularjs.org/1.3.0-beta.13/$injector/modulerr?p0=app&p1=%5Bng%3Aareq%5D%20Argument%20'fn'%20is%20not%20a%20function%2C%20got%20string%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.3.0-beta.13%2Fng%2Fareq%3Fp0%3Dfn%26p1%3Dnot%2520a%2520function%252C%2520got%2520string%0AminErr%2F%3C%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A78%0AassertArg%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A1581%0AassertArgFn%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A1592%0Aannotate%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A3356%0Ainvoke%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A4022%0ArunInvokeQueue%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A3950%0AcreateInjector%2FloadModules%2F%3C%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A3959%0AforEach%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A324%0AloadModules%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A3940%0AcreateInjector%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A3880%0Abootstrap%2FdoBootstrap%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A1504%0Abootstrap%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A1519%0AangularInit%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A1431%0A%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fangular.js%3A22856%0AjQuery.Callbacks%2Ffire%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fjquery-2.1.1.js%3A3073%0AjQuery.Callbacks%2Fself.fireWith%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fjquery-2.1.1.js%3A3185%0A.ready%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fjquery-2.1.1.js%3A3391%0Acompleted%40http%3A%2F%2Flocalhost%3A11881%2Fscripts%2Fjquery-2.1.1.js%3A3407%0A
Hi guys,
I noticed that you have Nuget packages for many of your labs outputs; but saveQueueing isn't available?
I'd be happy to assist with Nuget packaging if necessary but given you manage the others yourselves, is there any chance you could just include an additional Nuget package for saveQueueing?
Thanks,
Mark
I just upgraded to TS 5.2.2, and my app no longer builds with an error of "Property 'ajaxpost' does not exist on type 'BreezeConfig'. I jumped from version 4.0.5 to 5.2.2, so I'm not sure exactly when it stopped working. It looks like TS no longer supports using namespace declaration merging to add a function to a variable. I was able to fix it by updating the declaration to use interface declaration merging on BreezeConfig instead:
import { AjaxAdapter, BreezeConfig } from '../breeze-client';
declare module '../breeze-client' {
export interface BreezeConfig {
ajaxpost(ajaxAdapter?: AjaxAdapter): void;
}
}
When dynamically building breeze queries (I use the breeze JSON syntax), especially when using the great capability to use navigation properties, queries can get quite long. This in my view is the more common breeze-way issue than manually adding big parameters.
Unfortunately when using the ajax-post extension, only the withParameters-parameters are sent in the message body. The $filter, $select, ... parameters are still sent in the querystring, which tends to get too long.
There was a comment on the latest version that savequeuing should work with Angular out of the box now. I don't think that's the case because if Q/$q. I'm wondering if it would be ok, rather than passing in Q to savequeuing, to just pass in breeze and reference breeze.Q rather than window.Q.
Then it would work out of the box with angular, assuming using the breeze.angular.js to map $q to breeze's Q.
I changed the first few lines of savequeing like below which seems to work without redefining Q in any way: it just takes it from the breeze property. In general, instead of passing in window.breeze.Q as an argument, you could reference breeze.Q elsewhere in the code and eliminate the argument. Just a thought.
(function (definition, window) {
// rather than window.Q
if (window.breeze && window.breeze.Q) {
definition(window.breeze, window.breeze.Q);
} else if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// CommonJS or Node
var b = require('breeze');
var q = require('Q');
definition(b, q);
} else if (typeof define === "function" && define["amd"] && !window.breeze) {
// Requirejs / AMD
define(['breeze', 'Q'], definition);
} else {
throw new Error("Can't find breeze and/or Q");
}
}
Line 193 of breeze.saveQueuing.js,
function rememberAddedOriginalValues() {
// added entities normally don't have original values but these will now
var added = entities ?
entities.filter(function (e) { return e.entityAspect.entityState.isAdded(); }) :
self.entityManager.getChanges(null, breeze.EntityState.Added); <<---- line 193
added.forEach(function (entity) {
var props = entity.entityType.dataProperties;
var originalValues = entity.entityAspect.originalValues;
props.forEach(function (dp) {
if (dp.isPartOfKey) { return; }
originalValues[dp.name] = entity.getProperty(dp.name);
});
});
}
You meant to get the entities that are added. However, getChanges() only accept 1 argument. You ended up getting all entities from the entity manager. As a result of that, we won't be able to rejectChanges for any entity which failed to save (as originalValues map already overwritten by the above code).
You should be calling self.entityManager.getEntities(null, breeze.EntityState.Added) instead.
The repository does not install via bower. There is an error with angular-core.
$ bower install breeze-client
bower cached git://github.com/kriskowal/q.git#2.0.2
bower validate 2.0.2 against git://github.com/kriskowal/q.git#*
bower not-cached git://github.com/Breeze/bower-breeze-client.git#*
bower resolve git://github.com/Breeze/bower-breeze-client.git#*
bower download https://github.com/Breeze/bower-breeze-client/archive/1.5.4.tar.gz
bower extract breeze-client#* archive.tar.gz
bower resolved git://github.com/Breeze/bower-breeze-client.git#1.5.4
bower ENOTFOUND Package angular-core not found
the z-validate directive has the line
isInput ? linkForInput() : linkForNonInput();
with the linkForNonInput function simply adding z_error, z_invalid etc. properties to the scope.
Many custom angular directives (many examples, but calendars, autocompletes and multi select directives) will be encapsulated by a div. in these cases, making the div behave like the other input elements (i.e. calling the linkForInput function) would seem to make more sense. Could this be implemented or are there other ways the linkForNonInput directive should be used? Thank you
Can this be upgraded to work along with breeze-client 2.0.
We need getEntityGraph to work with breeze-client 2.0 and Angular 8.
Thank you !
Please fix undefined 'core' in line 282:
'&& core.stringStartsWith' - missing 'breeze', s/b '&& breeze.core.stringStartsWith'
Thank you!
I need the getEntityGraph function but I'm migrating my project to TypeScript.
I found the d.ts files after installing the package breeze-client-labs, however the typings are missing from the package.json file and when I try to import it, I get an error (module not found). Can you fix the typings ?
On the function "_createErrorFromResponse" the before-last line is:
proto._catchNoConnectionError(err);
which gave me undefined error for "proto" in case of bad communications.
In fact, I don't find any variable "proto" in scope of this function or its parent.
I've changed this to:
ctor.prototype._catchNoConnectionError(err);
And now it works fine.
This bug is also on the ShaprePoint DataService, although I did not test, since I do not use that. But it seems like the same problem and solution applies.
Regards
ztp
Any chance you can register this w/ npm for consumption with browserify / requireJS?
After getting some errors "Queued save failed: Converting circular structure to JSON" when saving in Breeze I tracked the issue down to the function rememberAddedOriginalValues in breeze.savequeuing.js
My theory is that the circular structure issue happens because the list of Added entities sometimes ends up containing Modified (and other?) entities.
On line ~189 after:
var added = entities ? entities.filter(function (e) { return e.entityAspect.entityState.isAdded(); }) : entities.filter(function (e) { return e.entityAspect.entityState.isAdded(); }) : self.entityManager.getChanges(null, breeze.EntityState.Added);
It looks like the array in added should contain only Added entities, however for some reason it sometimes contains other entries.
To remove these other entities I added this immediately after the previous lines to remove entities with entitystates other than Added:
for(var x = 0; x < added.length; x++) { if(added[x].entityAspect && added[x].entityAspect.entityState.name != breeze.EntityState.Added) { added.splice(x, 1); x--; } }
This at least seems to have sorted my issues.
Hi
I get an error "customHeaders is not defined" when using the "breeze.ajaxpost.js". Looking at the code, the variable customHeaders is defined in function divertAjaxImpl but used in other function processSettings (line 101). Guess you should define it globally
Hi,
Just wondering if there is anything to support Angular (as opposed to AngularJS) directives either planned, in progress etc?
We're in the process of moving our codebase from AngularJS and things like the zValidate directive would be handy to have.
Cheers,
Steve
In late 2014 Microsoft added support for the OData $batch operator. Currently the SharePoint data service adapter forces individual requests. It should add support for it. This will only work in Office 365 today, not on-premises SharePoint 2013 deployments.
fix with six lines of code to accompany this issue
an optional z-append-to directive on the same element allows the z-decorator to be appended to an element on which it "plays nicely" - usage case below
<div class="col-md-5" id="startTimeGroup">
<div class="input-group" >
<span class="input-group-addon">
<i class="fa fa-calendar"></i>
</span>
<input id="startDate" class="form-control" ng-model="vm.course.startTime" data-autoclose="1" placeholder="Date" bs-datepicker type="text"
data-min-date="{{vm.minDate}}" data-max-date="{{vm.maxDate}}"
**z-validate z-append-to="#startTimeGroup">**
When a navigation property is included in Sharepoint 2010 data adapter, the returned array is plain javascript objects instead of entity types.
It would be great to have better TypeScript support.
The form isn't able to be submitted - came across this strange error when I had an an input element bound to something that wasn't actually attached to an entity. Something like this works ok in Chrome, but fails in IE11 and FF31:
<form data-ng-submit="vm.submit()">
<input class="form-control" type="email" data-ng-model="vm.field1" required data-z-validate/>
<button>Submit</button>
</form>
Yeah, I know you shouldn't do this, but it was a copy-pasta error that other developers might also make.
Navigation property entity that has it's own navigation properties is not being instantiated.
Please consider changing breeze.labs.dataservice.sharepoint.js line 318 from:
if (entityType._mappedPropertiesCount <= Object.keys(node).length - 1) {
to
if (entityType._mappedPropertiesCount - entityType.navigationProperties.length <= Object.keys(node).length - 1) {
otherwise setNpValue returns null pointer error accessing entityAspect.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.