marmelab / admin-config Goto Github PK
View Code? Open in Web Editor NEWConfiguration API to describe an administration interface. Used by ng-admin and react-admin.
Configuration API to describe an administration interface. Used by ng-admin and react-admin.
Hi,
Opening an issue to leave a trace for anyone who would have the same problem.
Our users in France could use the date filter but a strange issue came up when they were overseas.
An infinite loop would decrease the date counter indefinitely, loading the page again and again with a different date (e.g. if the user is 2 timezones away from France, the date would change every 24/2=12 $digest cycle).
My solution was to remove date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
in DateField.js since in our case we don't want to display date in the the user's tz but in the resource's tz.
Currently, field can have a specified defaultValue to be used during entity creation.
However, defaultValue can only be a constant. This makes it impossible to use client-side auto-generated defaults.
While server-generated defaults are more secure in general, client-side ones can have some benefits.
An example can be found in ng-admin sources:
https://github.com/marmelab/ng-admin/blob/bd734ba347add0c2aed6ab995585fb723b04cbd7/examples/blog/config.js#L295
Here, the "created_at" field is being preset with a timestamp. However, the timestamp is created incorrectly, new Date()
is instantiated during the start of client application, not during the creation of the record, so all the records created during this admin section would have the same date value.
Other possible use cases include auto-generated IDs and passwords. Generating them at client would allow the admin to record or tweak them before saving the data to server.
Pull-request to implement the feature: #54
When a listview has 0 items, singleApiCall
still gets called.
My REST API doesn't have a nice way to handle this 'dead' call.
Hi,
I'm trying to use ng-admin
with an older browser (PhantomJS 1.9, backed by Safari 5).
It doesn't have Array.find, so I'm using this polyfill.
However, this breaks ng-admin
in another way, because this code attempts to iterate over array entries using "for .. in":
getMappedValue(value, entry) {
for (let i in this._maps) {
value = this._maps[i](value, entry);
}
return value;
}
It's not safe to iterate over arrays in this way, see e.g. this stackoverflow answer, as any functions which have been added to Array.prototype
will get returned along with all the array entries.
I believe that this and all other array loops in ng-admin
and admin-config
need converting to use a "for (var i = 0; i < array.length; i++) {
style loop instead.
A quick grep suggests that there are a great many such loops in ng-admin
and admin-config
:-(
An asterisk is added to the names of mandatory fields. However, required boolean fields are represented by checkboxes, and thus are already "mandatory", since there's no possible way not to fill them out.
Having them labeled with asterisks might convey a wrong idea to the user: that the fields HAVE to be ticked (as it "I agree to terms and conditions").
I'm trying to use a compound primary key.
The current code seems to expect a single field for an identifier, so I added:
RestangularProvider.addElementTransformer('users_organisation', function(element) {
element['id'] = element.users + '/' + element.organisation
return element;
});
However, this breaks down when users_organisation
is used as a foreign reference.
I'm trying to create a custom url
on an entity.
The identifierName
passed to my function seems to be of different types depending on where it was called from.
I added this to the start of my function:
console.log("URL FUNC", entityName, viewType, identifierValue, identifierName)
I see in chrome's console:
URL FUNC profile ShowView a98f8790-2d53-11e6-be94-eb7602da249b e {_name: "id", _detailLink: true, _type: "string", _order: null, _label: null…}_attributes: Object_cssClasses: null_defaultValue: null_detailLink: true_detailLinkRoute: "edit"_editable: true_flattenable: true_label: null_maps: Array[0]_name: "id"_order: null_pinned: false_template: ()_templateIncludesLabel: false_transforms: Array[0]_type: "string"_validation: Objectdashboard: truelist: true__proto__: Object
URL FUNC organisation listView 54dd74c8-2d53-11e6-831e-5be6dcb88be2 organisation
nga.field('foo.bar', 'json'); will always return empty. but nga.field('foo', 'json'); will show whole object and confirm bar key exists.
Can you add an open source license to this project?
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.