[IMP] web_tour: add button to consume all tours in debug_manager
Changes the api of the consume method on the web_tour.tour model so that it now takes in argument an array of tour names instead of a single tour name.
This commit is contained in:
@@ -10,5 +10,11 @@
|
||||
<script type="text/javascript" src="/web_tour/static/src/js/tour_service.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="assets_backend" name="tours backend assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javascript" src="/web_tour/static/src/js/debug_manager.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -14,10 +14,11 @@ class Tour(models.Model):
|
||||
user_id = fields.Many2one('res.users', string='Consumed by')
|
||||
|
||||
@api.model
|
||||
def consume(self, name):
|
||||
""" Sets tour 'name' as consumed for the current user, meaning that
|
||||
this tour won't be active anymore for that user """
|
||||
self.create({'name': name, 'user_id': self.env.uid})
|
||||
def consume(self, tour_names):
|
||||
""" Sets given tours as consumed, meaning that
|
||||
these tours won't be active anymore for that user """
|
||||
for name in tour_names:
|
||||
self.create({'name': name, 'user_id': self.env.uid})
|
||||
|
||||
@api.model
|
||||
def get_consumed_tours(self):
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
odoo.define('web_tour.DebugManager', function (require) {
|
||||
"use strict";
|
||||
|
||||
var DebugManager = require('web.DebugManager');
|
||||
var Model = require('web.Model');
|
||||
|
||||
var tour = require('web_tour.tour');
|
||||
|
||||
function get_active_tours () {
|
||||
return _.difference(_.keys(tour.tours), tour.consumed_tours);
|
||||
}
|
||||
|
||||
DebugManager.include({
|
||||
start: function () {
|
||||
this.consume_tours_enabled = get_active_tours().length > 0;
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
consume_tours: function () {
|
||||
var active_tours = get_active_tours();
|
||||
if (active_tours.length > 0) { // tours might have been consumed meanwhile
|
||||
new Model('web_tour.tour').call('consume', [active_tours]).then(function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
@@ -173,7 +173,9 @@ return core.Class.extend({
|
||||
this.running_tour = undefined;
|
||||
clearTimeout(this.running_tour_timeout);
|
||||
} else {
|
||||
this.TourModel.call('consume', [tour_name]);
|
||||
this.TourModel.call('consume', [[tour_name]]).then((function () {
|
||||
this.consumed_tours.push(tour_name);
|
||||
}).bind(this));
|
||||
}
|
||||
},
|
||||
_set_running_tour_timeout: function(tour_name, step) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-extend="WebClient.DebugManager.Global">
|
||||
<t t-jquery="li > a[data-action='start_tour']" t-operation="after">
|
||||
<li t-if="manager._is_admin and manager.consume_tours_enabled">
|
||||
<a href="#" data-action="consume_tours">Consume Tours</a>
|
||||
</li>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
Reference in New Issue
Block a user