Giter Site home page Giter Site logo

admin-config's Introduction

admin-config Build Status

Common files used in both ng-admin and ng-admin-react.

Installation

make install

Including In Another Library

Require whatever class you need directly.

// es5
var NumberField = require('admin-config/lib/Field/NumberField');
// es6
import NumberField from "admin-config/lib/Field/NumberField";

Admin-config is written in ES6. You'll need a transpiler to use any of the classes (we recommend Webpack and babel). Here is an example Webpack configuration:

module.exports = {
    // ...
    module: {
        loaders: [
            { test: /node_modules\/admin-config\/.*\.js$/, loader: 'babel' }
        ]
    }
};

Transpiling

In order to increase this library compatibility and to not force other users of this library to use Babel, you need to transpile your ES6 code from src/ to good old ES5 code (in lib/).

Just run:

make transpile

And you are done!

Running Tests

make test

admin-config's People

Contributors

capir avatar djhi avatar fzaninotto avatar jeromemacias avatar jniebuhr avatar jpetitcolas avatar justinm avatar lukemarsh avatar manuquentin avatar matsluni avatar richardbradley avatar rndstr avatar steveh-bipsync avatar tomy2105 avatar zyhou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

admin-config's Issues

Feature Request: allow using factory function as defaultValue for fields

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

Iterating over array entries using "for .. in" breaks if Array polyfills are used

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 :-(

identifierName inconsistent type

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

Infinite loop when user from a different timezone adds a date filter

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.

Required boolean fields should not be labeled with an asterisk

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").

Compound primary keys

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.