summaryrefslogtreecommitdiff
path: root/addons/survey/static/src/js/survey_breadcrumb.js
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/survey/static/src/js/survey_breadcrumb.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/survey/static/src/js/survey_breadcrumb.js')
-rw-r--r--addons/survey/static/src/js/survey_breadcrumb.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/addons/survey/static/src/js/survey_breadcrumb.js b/addons/survey/static/src/js/survey_breadcrumb.js
new file mode 100644
index 00000000..4cc3796f
--- /dev/null
+++ b/addons/survey/static/src/js/survey_breadcrumb.js
@@ -0,0 +1,50 @@
+odoo.define('survey.breadcrumb', function (require) {
+'use strict';
+
+var publicWidget = require('web.public.widget');
+
+publicWidget.registry.SurveyBreadcrumbWidget = publicWidget.Widget.extend({
+ xmlDependencies: ['/survey/static/src/xml/survey_breadcrumb_templates.xml'],
+ template: "survey.survey_breadcrumb_template",
+ events: {
+ 'click .breadcrumb-item a': '_onBreadcrumbClick',
+ },
+
+ /**
+ * @override
+ */
+ init: function (parent, options) {
+ this._super.apply(this, arguments);
+ this.canGoBack = options.canGoBack;
+ this.currentPageId = options.currentPageId;
+ this.pages = options.pages;
+ },
+
+ // Handlers
+ // -------------------------------------------------------------------
+
+ _onBreadcrumbClick: function (event) {
+ event.preventDefault();
+ this.trigger_up('breadcrumb_click', {
+ 'previousPageId': this.$(event.currentTarget)
+ .closest('.breadcrumb-item')
+ .data('pageId')
+ });
+ },
+
+ // PUBLIC METHODS
+ // -------------------------------------------------------------------
+
+ updateBreadcrumb: function (pageId) {
+ if (pageId) {
+ this.currentPageId = pageId;
+ this.renderElement();
+ } else {
+ this.$('.breadcrumb').addClass('d-none');
+ }
+ },
+});
+
+return publicWidget.registry.SurveyBreadcrumbWidget;
+
+});