-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameterize entities views. Global filters? Custom routes? #636
Comments
I asked a similar question in #627 you could try set a global variable when you access an app and then use that ID in all your other url functions. eg: var users = nga.entity('app')
.url(function(entity, view, id, element) {
window.app_id = id;
return 'app/' + ( id ? id+"/" : "" )
});
var categories = nga.entity('categories')
.url(function(entity, view, id, element) {
var app_id = window.app_id || 0
return 'categories/app/'+app_id+'/list'
}); (the parameters might be different - I think i was using the master branch) |
Is http://marmelab.com/blog/2015/08/26/ng-admin-0-8.html#permanent-filters |
Yes but it should look like |
You could if |
Is it possible to access |
@fzaninotto Hi! So I tried the
|
Doing anything else than the first suggestion would imply deep (and non-BC) changes to ng-admin routing. Related to #409 |
I do have the exact same concern. I need to implement a hard dependencies between the route. The first CRUD is a list of servers and you must select one server to get the next sub level. I manage using global variable (mention in previous post) to have a CRUD of the second level. However I get a HTTP/404 by default as no servers is selected. |
i have an entity with a custom url admin.addEntity(nga.entity('recent').url('customEdge')); then, in my dashboard ii make a restangular request on this entity Restangular
.one('recent')
.get()
... but the request is still made on /recent instead of /customEdge what i am missing? |
@cmnstmntmn you're mixing up two things:
When you customize an entity baseUrl, it is only taken into account in this entity - not in Restangular in general. |
yes, you're right. i like the entity way of doing things, but is hard to deal with scope logic, i think. the best example is the dashboard, in your demo; where both Restangular, used for dashboard-summary, and entities, for customizing panels, are used. can i alter data inside return nga.dashboard() .. before i extract it in custom directive? to make an ideea, from a single entity, having "versions":[
{"id":1, "name":"test 1"},
{"id":2, "name":"test 2"},
{"id":3, "name":"test 3"}
] can choices-field handle the state of some fields inside entity? |
i think i found the answer by reading on your blog ng-admin-callback-customization |
@fzaninotto is this a good aproach? dashboard/config.js export default function (nga, admin) {
return nga.dashboard()
.addCollection(nga.collection(admin.getEntity('recent'))
.name('id')
// .title('Monthly revenue')
.fields([
nga.field('id'),
nga.field('total', 'amount')
])
.sortField('date')
.sortDir('ASC')
.perPage(100)
)
.template(`<dashboard-summary name="{{ collection().name() }}"
entries="entries()"
fields="::collection().fields()"
entity="::collection().entity"
list-actions="::collection().listActions()"
datastore="datastore()"></dashboard-summary>`);
} dashboardSummary.js import dashboardSummaryTemplate from './dashboardSummary.html';
function dashboardSummary($state) {
return {
restrict: 'E',
scope: {
collection: '&',
entries: '&',
datastore: '&'
},
link: function (scope) {
scope.gotoList = function () {
$state.go($state.get('list'), { entity: scope.collection().entity.name() });
};
},
testsample: function (scope) {
console.log('ceva');
},
template: dashboardSummaryTemplate
};
}
dashboardSummary.$inject = ['$state'];
export default dashboardSummary; |
@cmnstmntmn: it looks good to me. We already use something similar in some of our custom directive. |
I think a global interceptor similar to the one described in #711 fits your need. I'm closing this issue, feel free to reopen if you need more assistance. |
@fzaninotto i am having the following edges
the object is {
"STATS": {
"count": 100
}
} then, in another entity, i'm trying to reference this entity, and do the math based on count value nga.field('stats', 'reference')
.targetEntity(admin.getEntity('stats'))
.targetField(nga.field('STATS'))
.permanentFilters({}) but it doesn't work, becauze the call is made to is there a way to call an api edge with static objects ? |
Nope, that's not very RESTY. But I did something similar in ng-admin demo, see marmelab/ng-admin-demo@a26c4e1 |
I have an
apps
entity which is the base model of my application.Every other entity is linked to it. e.g.
categories
have anappId
that reference an app.I can nest categories inside other categories if they have the same
appId
.I need to be able to edit an app's categories, thus displaying only categories with the same appId in my listView and in reference fields. For reference fields that means having a permanent filter with the selected appId.
Basically, when I select an
app
, I should modify every linked entities views accordingly so the data gets filtered right away.I could have a custom route :
categories/app/{appId}/list
I don't know if I'm making myself clear enough but the main ID is to parameterize every view according to the admin's state.
I need directions on how to do that...
Can anybody help please?
The text was updated successfully, but these errors were encountered: