How to use the routing.generate function in routing

To help you get started, we’ve selected a few routing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oroinc / platform / src / Oro / Bundle / ConfigBundle / Resources / public / js / app / views / configuration-tree-view.js View on Github external
redirect: function(node) {
            const parent = _.last(_.without(node.parents, '#'));
            const routeParams = _.extend({}, this.onSelectRouteParameters, {
                activeGroup: parent + '/' + node.id
            });

            const state = tools.unpackFromQueryString(location.search)[this.viewGroup] || {};
            if (_.isUndefined(routeParams[this.viewGroup])) {
                routeParams[this.viewGroup] = state;
            }
            const url = routing.generate(this.onSelectRoute, routeParams);
            // simulate click on real link to check page state
            const $link = $('<a>').attr('href', url);
            this.$tree.before($link);
            $link.click().remove();
        },
</a>
github oroinc / platform / src / Oro / Bundle / EntityBundle / Resources / public / js / app / models / entity-collection.js View on Github external
url: function(method, params) {
            const route = this.ROUTE[method];
            if (!route) {
                throw new Error('Method `' + method + '` is not supported by the collection');
            }
            return routing.generate(route, _.defaults({
                entity: this.type
            }, params));
        },
github oroinc / platform / src / Oro / Bundle / EntityBundle / Resources / public / js / app / models / entity-relationship-collection.js View on Github external
url: function(method, params) {
            return routing.generate(this.ROUTE[method], _.defaults({
                entity: this.type,
                id: this.id,
                association: this.association
            }, params));
        },
github oroinc / platform / src / Oro / Bundle / ActivityListBundle / Resources / public / js / app / views / activity-list-view.js View on Github external
_getUrl: function(actionKey, model) {
            const routes = model.get('routes');

            return routing.generate(routes[actionKey], {
                entity: model.get('relatedActivityClass'),
                id: model.get('relatedActivityId')
            });
        },
github oroinc / platform / src / Oro / Bundle / EntityBundle / Resources / public / js / app / models / entity-model.js View on Github external
url: function(method, params) {
            return routing.generate(this.ROUTE[method], _.defaults({entity: this.type, id: this.id}, params));
        },
github oroinc / platform / src / Oro / Bundle / EmailBundle / Resources / public / js / app / views / email-thread-view.js View on Github external
loadEmails: function() {
            let url;
            let promise;
            const ids = this.$(this.selectors.loadMore).addClass('process').data('emailsItems');
            if (ids) {
                url = routing.generate('oro_email_items_view', {ids: ids.join(',')});
                promise = $.ajax(url)
                    .done(_.bind(this.onDoneLoadEmails, this))
                    .fail(_.bind(this.onFailLoadEmails, this));
            } else {
                promise = $.Deferred().resolve('').promise();
            }
            return promise;
        },
github oroinc / platform / src / Oro / Bundle / NavigationBundle / Resources / public / js / app / models / base / model.js View on Github external
url: function() {
            let base = _.result(this, 'urlRoot') || _.result(this.collection, 'url');
            if (base && base.indexOf(this.get('type')) === -1) {
                base += (base.charAt(base.length - 1) === '/' ? '' : '/') + this.get('type');
            } else if (!base) {
                base = routing.generate(this.route, {type: this.get('type')});
            }
            if (this.isNew()) {
                return base;
            }
            return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + 'ids/' + encodeURIComponent(this.id);
        }
    });
github oroinc / platform / src / Oro / Bundle / ImportExportBundle / Resources / public / js / importexport-manager.js View on Github external
handleTemplate: function() {
            if (!this.options.exportTemplateProcessor) {
                throw new TypeError('"exportTemplateProcessor" is required');
            }

            let exportTemplateUrl;

            if (this.options.isExportTemplatePopupRequired) {
                exportTemplateUrl = routing.generate(
                    this.options.exportTemplateConfigRoute,
                    $.extend({}, this.routeOptions, {
                        processorAlias: this.options.exportTemplateProcessor
                    })
                );

                this._renderDialogWidget({
                    url: exportTemplateUrl,
                    dialogOptions: {
                        title: this.options.exportTemplateTitle
                    }
                });
            } else {
                exportTemplateUrl = routing.generate(
                    this.options.exportTemplateRoute,
                    $.extend({}, this.routeOptions, {
github oroinc / platform / src / Oro / Bundle / FormBundle / Resources / public / js / app / components / autocomplete-component.js View on Github external
this.options = $.extend(true, thisOptions, this.options, options || {});
            this.$el = options._sourceElement;

            this.$el.attr('autocomplete', 'off');

            const dropClasses = this.$el.data('dropdown-classes');
            if (dropClasses) {
                this.options.config = _.assign(this.options.config, {
                    holder: '<div class="' + dropClasses.holder + '"></div>',
                    menu: '<ul class="' + dropClasses.menu + '"></ul>',
                    item: '<li class="' + dropClasses.item + '"><a href="#" class="' + dropClasses.link + '"></a></li>'
                });
            }

            if (this.options.route_name) {
                this.url = routing.generate(
                    this.options.route_name,
                    this.options.route_parameters
                );
            }

            if (!_.isFunction(this.options.selection_template) &amp;&amp; !_.isEmpty(this.options.selection_template)) {
                this.options.selection_template = _.template(this.options.selection_template);
            }

            this.$el.typeahead(this.options.config);
        },
github oroinc / platform / src / Oro / Bundle / CommentBundle / Resources / public / js / app / models / comment-model.js View on Github external
url: function() {
            let url;
            let parameters;
            if (this.isNew()) {
                if (!this.get('relationClass') || !this.get('relationId')) {
                    throw new Error('Please specify relationClass and relationId');
                }
                parameters = {
                    relationId: this.get('relationId'),
                    relationClass: this.get('relationClass')
                };
                url = routing.generate('oro_api_comment_get_items', parameters);
            } else {
                parameters = {
                    id: this.get('id'),
                    _format: 'json'
                };
                url = routing.generate(this.route, parameters);
            }
            return url;
        },

routing

Automatic routing based on express

Unknown
Latest version published 13 years ago

Package Health Score

36 / 100
Full package analysis

Popular routing functions