[REF] website_forum: update to the new module system

This commit is contained in:
Géry Debongnie
2015-03-18 09:23:35 +01:00
parent da73f624b2
commit be8adf2769
5 changed files with 547 additions and 518 deletions
@@ -1,34 +1,39 @@
(function() {
"use strict";
odoo.define('website_forum.editor', ['web.core', 'website.contentMenu', 'website.website'], function (require) {
"use strict";
var website = openerp.website;
var _t = openerp._t;
var core = require('web.core');
var contentMenu = require('website.contentMenu');
var website = require('website.website');
website.EditorBarContent.include({
new_forum: function() {
website.prompt({
id: "editor_new_forum",
window_title: _t("New Forum"),
input: "Forum Name",init: function () {
var $group = this.$dialog.find("div.form-group");
$group.removeClass("mb0");
var _t = core._t;
var $add = $(
'<div class="form-group mb0">'+
'<label class="col-sm-offset-3 col-sm-9 text-left">'+
' <input type="checkbox" required="required"/> '+
'</label>'+
'</div>');
$add.find('label').append(_t("Add page in menu"));
$group.after($add);
}
}).then(function (forum_name, field, $dialog) {
var add_menu = ($dialog.find('input[type="checkbox"]').is(':checked'));
website.form('/forum/new', 'POST', {
forum_name: forum_name,
add_menu: add_menu || ""
});
contentMenu.EditorBarContent.include({
new_forum: function() {
website.prompt({
id: "editor_new_forum",
window_title: _t("New Forum"),
input: "Forum Name",init: function () {
var $group = this.$dialog.find("div.form-group");
$group.removeClass("mb0");
var $add = $(
'<div class="form-group mb0">'+
'<label class="col-sm-offset-3 col-sm-9 text-left">'+
' <input type="checkbox" required="required"/> '+
'</label>'+
'</div>');
$add.find('label').append(_t("Add page in menu"));
$group.after($add);
}
}).then(function (forum_name, field, $dialog) {
var add_menu = ($dialog.find('input[type="checkbox"]').is(':checked'));
}).then(function (forum_name) {
website.form('/forum/new', 'POST', {
forum_name: forum_name,
add_menu: add_menu || ""
});
},
});
})();
});
},
});
});
@@ -1,250 +1,261 @@
odoo.define('website_forum.website_forum', ['web.ajax', 'web.core', 'website.website'], function (require) {
'use strict';
openerp.website.if_dom_contains('.website_forum', function () {
var _t = openerp._t;
$("[data-toggle='popover']").popover();
$('.karma_required').on('click', function (ev) {
var karma = $(ev.currentTarget).data('karma');
if (karma) {
ev.preventDefault();
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="karma_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
karma + _t(' karma is required to perform this action. You can earn karma by having your answers upvoted by the community.')+
'</div>');
var vote_alert = $(ev.currentTarget).parent().find("#vote_alert");
if (vote_alert.length == 0) {
$(ev.currentTarget).parent().append($warning);
}
var ajax = require('web.ajax');
var core = require('web.core');
var website = require('website.website');
var _t = core._t;
var lastsearch;
website.if_dom_contains('.website_forum', function () {
$("[data-toggle='popover']").popover();
$('.karma_required').on('click', function (ev) {
var karma = $(ev.currentTarget).data('karma');
if (karma) {
ev.preventDefault();
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="karma_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
karma + _t(' karma is required to perform this action. You can earn karma by having your answers upvoted by the community.') + '</div>');
var vote_alert = $(ev.currentTarget).parent().find("#vote_alert");
if (vote_alert.length == 0) {
$(ev.currentTarget).parent().append($warning);
}
});
}
});
$('.vote_up,.vote_down').not('.karma_required').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
openerp.jsonRpc($link.data('href'), 'call', {})
.then(function (data) {
if (data['error']){
if (data['error'] == 'own_post'){
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
_t('Sorry, you cannot vote for your own posts')+
'</div>');
} else if (data['error'] == 'anonymous_user'){
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
_t('Sorry you must be logged to vote')+
'</div>');
}
vote_alert = $link.parent().find("#vote_alert");
if (vote_alert.length == 0) {
$link.parent().append($warning);
}
} else {
$link.parent().find(".vote_count").html(data['vote_count']);
if (data['user_vote'] == 0) {
$link.parent().find(".text-success").removeClass("text-success");
$link.parent().find(".text-warning").removeClass("text-warning");
} else {
if (data['user_vote'] == 1) {
$link.addClass("text-success");
} else {
$link.addClass("text-warning");
}
}
}
});
});
$('.accept_answer').not('.karma_required').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
openerp.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
if (data['error']) {
if (data['error'] == 'anonymous_user') {
var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
$('.vote_up,.vote_down').not('.karma_required').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
ajax.jsonRpc($link.data('href'), 'call', {})
.then(function (data) {
if (data.error){
if (data.error == 'own_post'){
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
_t('Sorry, anonymous users cannot choose correct answer.')+
_t('Sorry, you cannot vote for your own posts') +
'</div>');
} else if (data.error == 'anonymous_user'){
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
_t('Sorry you must be logged to vote') +
'</div>');
}
correct_answer_alert = $link.parent().find("#correct_answer_alert");
if (correct_answer_alert.length == 0) {
var vote_alert = $link.parent().find("#vote_alert");
if (vote_alert.length === 0) {
$link.parent().append($warning);
}
} else {
if (data) {
$(".oe_answer_true").addClass('oe_answer_false').removeClass("oe_answer_true");
$link.addClass("oe_answer_true").removeClass('oe_answer_false');
$link.parent().find(".vote_count").html(data['vote_count']);
if (data.user_vote === 0) {
$link.parent().find(".text-success").removeClass("text-success");
$link.parent().find(".text-warning").removeClass("text-warning");
} else {
$link.removeClass("oe_answer_true").addClass('oe_answer_false');
if (data.user_vote === 1) {
$link.addClass("text-success");
} else {
$link.addClass("text-warning");
}
}
}
});
});
});
$('.favourite_question').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
openerp.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
$('.accept_answer').not('.karma_required').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
ajax.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
if (data.error) {
if (data.error == 'anonymous_user') {
var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
_t('Sorry, anonymous users cannot choose correct answer.') +
'</div>');
}
var correct_answer_alert = $link.parent().find("#correct_answer_alert");
if (correct_answer_alert.length == 0) {
$link.parent().append($warning);
}
} else {
if (data) {
$link.addClass("forum_favourite_question")
$(".oe_answer_true").addClass('oe_answer_false').removeClass("oe_answer_true");
$link.addClass("oe_answer_true").removeClass('oe_answer_false');
} else {
$link.removeClass("forum_favourite_question")
$link.removeClass("oe_answer_true").addClass('oe_answer_false');
}
});
});
$('.comment_delete').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
openerp.jsonRpc($link.parent('form').attr('action'), 'call', {}).then(function (data) {
$link.parents('.comment').first().remove();
});
});
$('.notification_close').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
openerp.jsonRpc("/forum/notification_read", 'call', {
'notification_id': $link.attr("id")});
});
$('.send_validation_email').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
openerp.jsonRpc("/forum/send_validation_email", 'call', {
'forum_id': $link.attr('forum-id'),
}).then(function (data) {
if (data) {
$('button.validation_email_close').click();
}
});
});
$('.validated_email_close').on('click', function (ev) {
openerp.jsonRpc("/forum/validate_email/close", 'call', {});
});
// welcome message action button
var forum_login = _.string.sprintf('%s/web?redirect=%s',
window.location.origin, escape(window.location.href));
$('.forum_register_url').attr('href',forum_login);
$('.js_close_intro').on('click', function (ev) {
ev.preventDefault();
document.cookie = "forum_welcome_message = false";
$('.forum_intro').slideUp();
return true;
});
$('.link_url').on('change', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
var display_error = function(){
var $warning = $('<div class="alert alert-danger alert-dismissable" style="position:absolute; margin-top: -180px; margin-left: 90px;">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
'Please enter valid URL. Example: http://www.odoo.com'+
'</div>');
$link.parent().append($warning);
$("button#btn_post_your_article")[0].disabled = true;
};
var url = $link.val();
if (url.search("^http(s?)://.*")) {
url = 'http://'+url;
}
var regex = new RegExp("(http(s)?://.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)");
if(regex.test(url)){
openerp.jsonRpc("/forum/get_url_title", 'call', {'url': url}).then(function (data) {
if(data){
$("input[name='post_name']")[0].value = data;
$('button#btn_post_your_article').prop('disabled', false);
}else{
display_error();
}
});
}else{
display_error();
}
});
$('input.js_select2').select2({
tags: true,
tokenSeparators: [",", " ", "_"],
maximumInputLength: 35,
minimumInputLength: 2,
maximumSelectionSize: 5,
lastsearch: [],
createSearchChoice: function (term) {
if ($(lastsearch).filter(function () { return this.text.localeCompare(term) === 0;}).length === 0) {
//check Karma
if (parseInt($("#karma").val()) >= parseInt($("#karma_retag").val())) {
return {
id: "_" + $.trim(term),
text: $.trim(term) + ' *',
isNew: true,
};
}
}
},
formatResult: function(term) {
if (term.isNew) {
return '<span class="label label-primary">New</span> ' + _.escape(term.text);
}
else {
return _.escape(term.text);
}
},
ajax: {
url: '/forum/get_tags',
dataType: 'json',
data: function(term, page) {
return {
q: term,
l: 50
};
},
results: function(data, page) {
var ret = [];
_.each(data, function(x) {
ret.push({ id: x.id, text: x.name, isNew: false });
});
lastsearch = ret;
return { results: ret };
}
},
// Take default tags from the input value
initSelection: function (element, callback) {
var data = [];
_.each(element.data('init-value'), function(x) {
data.push({ id: x.id, text: x.name, isNew: false });
});
element.val('');
callback(data);
},
});
$('textarea.load_editor').each(function () {
var $textarea = $(this);
var editor_karma = $textarea.data('karma') || 30; // default value for backward compatibility
if (!$textarea.val().match(/\S/)) {
$textarea.val("<p><br/></p>");
}
var $form = $textarea.closest('form');
var toolbar = [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']]
];
if (parseInt($("#karma").val()) >= editor_karma) {
toolbar.push(['insert', ['link', 'picture']]);
}
$textarea.summernote({
height: 150,
toolbar: toolbar
});
$form.on('click', 'button, .a-submit', function () {
$textarea.html($form.find('.note-editable').code());
});
});
});
$('.favourite_question').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
ajax.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
if (data) {
$link.addClass("forum_favourite_question")
} else {
$link.removeClass("forum_favourite_question")
}
});
});
$('.comment_delete').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
ajax.jsonRpc($link.parent('form').attr('action'), 'call', {}).then(function () {
$link.parents('.comment').first().remove();
});
});
$('.notification_close').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
ajax.jsonRpc("/forum/notification_read", 'call', {
'notification_id': $link.attr("id")});
});
$('.send_validation_email').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
ajax.jsonRpc("/forum/send_validation_email", 'call', {
'forum_id': $link.attr('forum-id'),
}).then(function (data) {
if (data) {
$('button.validation_email_close').click();
}
});
});
$('.validated_email_close').on('click', function (ev) {
ajax.jsonRpc("/forum/validate_email/close", 'call', {});
});
// welcome message action button
var forum_login = _.string.sprintf('%s/web?redirect=%s',
window.location.origin, escape(window.location.href));
$('.forum_register_url').attr('href',forum_login);
$('.js_close_intro').on('click', function (ev) {
ev.preventDefault();
document.cookie = "forum_welcome_message = false";
$('.forum_intro').slideUp();
return true;
});
$('.link_url').on('change', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
var display_error = function(){
var $warning = $('<div class="alert alert-danger alert-dismissable" style="position:absolute; margin-top: -180px; margin-left: 90px;">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
'Please enter valid URL. Example: http://www.odoo.com'+
'</div>');
$link.parent().append($warning);
$("button#btn_post_your_article")[0].disabled = true;
};
var url = $link.val();
if (url.search("^http(s?)://.*")) {
url = 'http://'+url;
}
var regex = new RegExp("(http(s)?://.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)");
if(regex.test(url)){
ajax.jsonRpc("/forum/get_url_title", 'call', {'url': url}).then(function (data) {
if(data){
$("input[name='post_name']")[0].value = data;
$('button#btn_post_your_article').prop('disabled', false);
}else{
display_error();
}
});
} else {
display_error();
}
});
$('input.js_select2').select2({
tags: true,
tokenSeparators: [",", " ", "_"],
maximumInputLength: 35,
minimumInputLength: 2,
maximumSelectionSize: 5,
lastsearch: [],
createSearchChoice: function (term) {
if ($(lastsearch).filter(function () { return this.text.localeCompare(term) === 0;}).length === 0) {
//check Karma
if (parseInt($("#karma").val()) >= parseInt($("#karma_retag").val())) {
return {
id: "_" + $.trim(term),
text: $.trim(term) + ' *',
isNew: true,
};
}
}
},
formatResult: function(term) {
if (term.isNew) {
return '<span class="label label-primary">New</span> ' + _.escape(term.text);
}
else {
return _.escape(term.text);
}
},
ajax: {
url: '/forum/get_tags',
dataType: 'json',
data: function(term) {
return {
q: term,
l: 50
};
},
results: function(data) {
var ret = [];
_.each(data, function(x) {
ret.push({ id: x.id, text: x.name, isNew: false });
});
lastsearch = ret;
return { results: ret };
}
},
// Take default tags from the input value
initSelection: function (element, callback) {
var data = [];
_.each(element.data('init-value'), function(x) {
data.push({ id: x.id, text: x.name, isNew: false });
});
element.val('');
callback(data);
},
});
$('textarea.load_editor').each(function () {
var $textarea = $(this);
var editor_karma = $textarea.data('karma') || 30; // default value for backward compatibility
if (!$textarea.val().match(/\S/)) {
$textarea.val("<p><br/></p>");
}
var $form = $textarea.closest('form');
var toolbar = [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']]
];
if (parseInt($("#karma").val()) >= editor_karma) {
toolbar.push(['insert', ['link', 'picture']]);
}
$textarea.summernote({
height: 150,
toolbar: toolbar
});
$form.on('click', 'button, .a-submit', function () {
$textarea.html($form.find('.note-editable').code());
});
});
});
});
@@ -1,59 +1,66 @@
(function () {
'use strict';
odoo.define('website_forum.share', ['web.ajax', 'web.core', 'website.share', 'website.website'], function (require) {
'use strict';
var website = openerp.website;
var qweb = openerp.qweb;
website.add_template_file('/website_forum/static/src/xml/website_forum_share_templates.xml');
var ajax = require('web.ajax');
var core = require('web.core');
var SocialShare = require('website.share');
var website = require('website.website');
website.forum_share = website.social_share.extend({
init: function (parent, target_type) {
this.target_type = target_type;
this._super(parent);
},
bind_events: function () {
this._super.apply(this, arguments);
$('.oe_share_bump').click($.proxy(this.post_bump, this));
},
renderElement: function () {
if (! this.target_type) {
this._super();
}
else if (this.target_type == 'social-alert') {
$('.row .question').before(qweb.render('website.social_alert', {medias: this.social_list}));
}
else {
this.template = 'website.social_modal';
$('body').append(qweb.render(this.template, {medias: this.social_list, target_type: this.target_type}));
$('#oe_social_share_modal').modal('show');
}
},
post_bump: function () {
openerp.jsonRpc('/forum/post/bump', 'call', {
'post_id': this.element.data('id'),
});
var qweb = core.qweb;
website.add_template_file('/website_forum/static/src/xml/website_forum_share_templates.xml');
var ForumShare = SocialShare.extend({
init: function (parent, target_type) {
this.target_type = target_type;
this._super(parent);
},
bind_events: function () {
this._super.apply(this, arguments);
$('.oe_share_bump').click($.proxy(this.post_bump, this));
},
renderElement: function () {
if (! this.target_type) {
this._super();
}
});
website.ready().done(function() {
// Store social share data to display modal on next page
$(document.body).on('click', '.oe_social_share_call', function() {
var social_data = {};
social_data['target_type'] = $(this).data('social-target-type');
sessionStorage.setItem('social_share', JSON.stringify(social_data));
else if (this.target_type == 'social-alert') {
$('.row .question').before(qweb.render('website.social_alert', {medias: this.social_list}));
}
else {
this.template = 'website.social_modal';
$('body').append(qweb.render(this.template, {medias: this.social_list, target_type: this.target_type}));
$('#oe_social_share_modal').modal('show');
}
},
post_bump: function () {
ajax.jsonRpc('/forum/post/bump', 'call', {
'post_id': this.element.data('id'),
});
}
});
// Retrieve stored social data
if(sessionStorage.getItem('social_share')){
var social_data = JSON.parse(sessionStorage.getItem('social_share'));
new website.forum_share($(this), social_data['target_type']);
sessionStorage.removeItem('social_share');
}
website.ready().done(function() {
// Display an alert if post has no reply and is older than 10 days
if ($('.oe_js_bump').length) {
var $question_container = $('.oe_js_bump');
new website.forum_share($question_container, 'social-alert');
}
// Store social share data to display modal on next page
$(document.body).on('click', '.oe_social_share_call', function() {
var social_data = {};
social_data['target_type'] = $(this).data('social-target-type');
sessionStorage.setItem('social_share', JSON.stringify(social_data));
});
})();
// Retrieve stored social data
if(sessionStorage.getItem('social_share')){
var social_data = JSON.parse(sessionStorage.getItem('social_share'));
new ForumShare($(this), social_data['target_type']);
sessionStorage.removeItem('social_share');
}
// Display an alert if post has no reply and is older than 10 days
if ($('.oe_js_bump').length) {
var $question_container = $('.oe_js_bump');
new ForumShare($question_container, 'social-alert');
}
});
return ForumShare;
});
@@ -1,124 +1,128 @@
(function () {
'use strict';
var _t = openerp._t;
odoo.define('website_forum.tour_forum', ['web.core', 'web.Tour'], function (require) {
'use strict';
openerp.Tour.register({
id: 'question',
name: _t("Create a question"),
steps: [
{
title: _t("Create a Question!"),
content: _t("Let's go through the first steps to create a new question."),
popover: { next: _t("Start Tutorial"), end: _t("Skip It") },
},
{
title: _t("Add Content"),
element: '#content-menu-button',
placement: 'left',
content: _t("Use this <em>'Content'</em> menu to create a new forum like any other document (page, menu, products, event, ...)."),
popover: { fixed: true },
},
{
title: _t("New Forum"),
element: 'a[data-action=new_forum]',
placement: 'left',
content: _t("Select this menu item to create a new forum."),
popover: { fixed: true },
},
{
title: _t("Forum Name"),
element: '.modal #editor_new_forum input[type=text]',
sampleText:'New Forum',
placement: 'right',
content: _t("Enter a name for your new forum then click 'Continue'."),
},
{
title: _t("Create Forum"),
waitNot: ".modal #editor_new_forum input[type=text]:propValue('')",
element: '.modal button.btn-primary',
placement: 'right',
content: _t("Click <em>Continue</em> to create the forum."),
},
{
title: _t("New Forum Created"),
waitFor: 'body:not(.modal-open)',
content: _t("This page contains all the information related to the new forum."),
popover: { next: _t("Continue") },
},
{
title: _t("Ask a Question"),
element: '.btn-block a:first',
placement: 'left',
content: _t("Ask the question in this forum by clicking on the button."),
},
{
title: _t("Question Title"),
element: 'input[name=post_name]',
sampleText:'First Question Title',
placement: 'top',
content: _t("Give your question title."),
},
{
title: _t("Question"),
waitNot: "input[name=post_name]:propValue('')",
element: '.note-editable p',
sampleText: 'First Question',
placement: 'top',
content: _t("Put your question here."),
},
{
title: _t("Give Tag"),
waitFor: '.note-editable:not(:has(br))',
element: '.select2-choices',
placement: 'top',
content: _t("Insert tags related to your question."),
},
{
title: _t("Post Question"),
waitNot: "input[id=s2id_autogen2]:propValue('Tags')",
element: 'button:contains("Post Your Question")',
placement: 'bottom',
content: _t("Click to post your question."),
},
{
title: _t("New Question Created"),
waitFor: 'body:has(".fa-star")',
content: _t("This page contain new created question."),
popover: { next: _t("Continue") },
},
{
title: _t("Answer"),
element: '.note-editable p',
sampleText: 'First Answer',
placement: 'top',
content: _t("Put your answer here."),
},
{
title: _t("Post Answer"),
waitFor: '.note-editable:not(:has(br))',
element: 'button:contains("Post Answer")',
placement: 'bottom',
content: _t("Click to post your answer."),
},
{
title: _t("Answer Posted"),
waitFor: 'body:has(".fa-check-circle")',
content: _t("This page contain new created question and its answer."),
popover: { next: _t("Continue") },
},
{
title: _t("Accept Answer"),
element: 'a[data-karma="20"]:first',
placement: 'right',
content: _t("Click here to accept this answer."),
},
{
title: _t("Congratulations"),
waitFor: 'body:has(".oe_answer_true")',
content: _t("Congratulations! You just created and post your first question and answer."),
popover: { next: _t("Close Tutorial") },
},
]
});
var core = require('web.core');
var Tour = require('web.Tour');
}());
var _t = core._t;
Tour.register({
id: 'question',
name: _t("Create a question"),
steps: [
{
title: _t("Create a Question!"),
content: _t("Let's go through the first steps to create a new question."),
popover: { next: _t("Start Tutorial"), end: _t("Skip It") },
},
{
title: _t("Add Content"),
element: '#content-menu-button',
placement: 'left',
content: _t("Use this <em>'Content'</em> menu to create a new forum like any other document (page, menu, products, event, ...)."),
popover: { fixed: true },
},
{
title: _t("New Forum"),
element: 'a[data-action=new_forum]',
placement: 'left',
content: _t("Select this menu item to create a new forum."),
popover: { fixed: true },
},
{
title: _t("Forum Name"),
element: '.modal #editor_new_forum input[type=text]',
sampleText:'New Forum',
placement: 'right',
content: _t("Enter a name for your new forum then click 'Continue'."),
},
{
title: _t("Create Forum"),
waitNot: ".modal #editor_new_forum input[type=text]:propValue('')",
element: '.modal button.btn-primary',
placement: 'right',
content: _t("Click <em>Continue</em> to create the forum."),
},
{
title: _t("New Forum Created"),
waitFor: 'body:not(.modal-open)',
content: _t("This page contains all the information related to the new forum."),
popover: { next: _t("Continue") },
},
{
title: _t("Ask a Question"),
element: '.btn-block a:first',
placement: 'left',
content: _t("Ask the question in this forum by clicking on the button."),
},
{
title: _t("Question Title"),
element: 'input[name=post_name]',
sampleText:'First Question Title',
placement: 'top',
content: _t("Give your question title."),
},
{
title: _t("Question"),
waitNot: "input[name=post_name]:propValue('')",
element: '.note-editable p',
sampleText: 'First Question',
placement: 'top',
content: _t("Put your question here."),
},
{
title: _t("Give Tag"),
waitFor: '.note-editable:not(:has(br))',
element: '.select2-choices',
placement: 'top',
content: _t("Insert tags related to your question."),
},
{
title: _t("Post Question"),
waitNot: "input[id=s2id_autogen2]:propValue('Tags')",
element: 'button:contains("Post Your Question")',
placement: 'bottom',
content: _t("Click to post your question."),
},
{
title: _t("New Question Created"),
waitFor: 'body:has(".fa-star")',
content: _t("This page contain new created question."),
popover: { next: _t("Continue") },
},
{
title: _t("Answer"),
element: '.note-editable p',
sampleText: 'First Answer',
placement: 'top',
content: _t("Put your answer here."),
},
{
title: _t("Post Answer"),
waitFor: '.note-editable:not(:has(br))',
element: 'button:contains("Post Answer")',
placement: 'bottom',
content: _t("Click to post your answer."),
},
{
title: _t("Answer Posted"),
waitFor: 'body:has(".fa-check-circle")',
content: _t("This page contain new created question and its answer."),
popover: { next: _t("Continue") },
},
{
title: _t("Accept Answer"),
element: 'a[data-karma="20"]:first',
placement: 'right',
content: _t("Click here to accept this answer."),
},
{
title: _t("Congratulations"),
waitFor: 'body:has(".oe_answer_true")',
content: _t("Congratulations! You just created and post your first question and answer."),
popover: { next: _t("Close Tutorial") },
},
]
});
});
@@ -1,87 +1,89 @@
(function () {
'use strict';
odoo.define('website_forum.tour_forum_question', ['web.Tour'], function (require) {
'use strict';
openerp.Tour.register({
id: 'forum_question',
name: "try to create question",
path: '/forum/help-1',
mode: 'test',
steps: [
{
title: "Ask a Question",
element: '.btn-block a:first',
placement: 'left',
content: "Ask the question in this forum by clicking on the button.",
},
{
title: "Question Title",
element: 'input[name=post_name]',
sampleText:'First Question Title',
placement: 'top',
content: "Give your question title.",
},
{
title: "Question",
waitNot: "input[name=post_name]:propValue('')",
element: '.note-editable p',
sampleText: 'First Question',
placement: 'top',
content: "Put your question here.",
},
{
title: "Give Tag",
waitFor: '.note-editable:not(:has(br))',
element: '.select2-choices',
sampleText:'Tag',
placement: 'top',
content: "Insert tags related to your question.",
},
{
title: "Post Question",
waitNot: "input[id=s2id_autogen2]:propValue('')",
element: 'button:contains("Post Your Question")',
placement: 'bottom',
content: "Click to post your question.",
},
{
title: "New Question Created",
waitFor: 'body:has(".fa-star")',
content: "This page contain new created question.",
popover: { next: "Continue" },
},
{
title: "Answer",
element: '.note-editable p',
sampleText: 'First Answer',
placement: 'top',
content: "Put your answer here.",
},
{
title: "Post Answer",
waitFor: '.note-editable:not(:has(br))',
element: 'button:contains("Post Answer")',
placement: 'bottom',
content: "Click to post your answer.",
},
{
title: "Answer Posted",
waitFor: 'body:has(".fa-check-circle")',
content: "This page contain new created question and its answer.",
popover: { next: "Continue" },
},
{
title: "Accept Answer",
element: 'a[data-karma="20"]:first',
placement: 'right',
content: "Click here to accept this answer.",
},
{
title: "Congratulations",
waitFor: 'body:has(".oe_answer_true")',
content: "Congratulations! You just created and post your first question and answer.",
popover: { next: "Close Tutorial" },
},
]
});
var Tour = require('web.Tour');
}());
Tour.register({
id: 'forum_question',
name: "try to create question",
path: '/forum/help-1',
mode: 'test',
steps: [
{
title: "Ask a Question",
element: '.btn-block a:first',
placement: 'left',
content: "Ask the question in this forum by clicking on the button.",
},
{
title: "Question Title",
element: 'input[name=post_name]',
sampleText:'First Question Title',
placement: 'top',
content: "Give your question title.",
},
{
title: "Question",
waitNot: "input[name=post_name]:propValue('')",
element: '.note-editable p',
sampleText: 'First Question',
placement: 'top',
content: "Put your question here.",
},
{
title: "Give Tag",
waitFor: '.note-editable:not(:has(br))',
element: '.select2-choices',
sampleText:'Tag',
placement: 'top',
content: "Insert tags related to your question.",
},
{
title: "Post Question",
waitNot: "input[id=s2id_autogen2]:propValue('')",
element: 'button:contains("Post Your Question")',
placement: 'bottom',
content: "Click to post your question.",
},
{
title: "New Question Created",
waitFor: 'body:has(".fa-star")',
content: "This page contain new created question.",
popover: { next: "Continue" },
},
{
title: "Answer",
element: '.note-editable p',
sampleText: 'First Answer',
placement: 'top',
content: "Put your answer here.",
},
{
title: "Post Answer",
waitFor: '.note-editable:not(:has(br))',
element: 'button:contains("Post Answer")',
placement: 'bottom',
content: "Click to post your answer.",
},
{
title: "Answer Posted",
waitFor: 'body:has(".fa-check-circle")',
content: "This page contain new created question and its answer.",
popover: { next: "Continue" },
},
{
title: "Accept Answer",
element: 'a[data-karma="20"]:first',
placement: 'right',
content: "Click here to accept this answer.",
},
{
title: "Congratulations",
waitFor: 'body:has(".oe_answer_true")',
content: "Congratulations! You just created and post your first question and answer.",
popover: { next: "Close Tutorial" },
},
]
});
});