[IMP] improved view, added hirachy view of documentation,show documentaion menu in hirarcy.
bzr revid: tpa@tinyerp.com-20140417112844-swv8lznyead51j4t
This commit is contained in:
parent
99020f41a6
commit
f9ab97d869
|
@ -21,7 +21,7 @@ class WebsiteDoc(http.Controller):
|
|||
def documentation(self, toc='', **kwargs):
|
||||
cr, uid, context, toc_id = request.cr, request.uid, request.context, False
|
||||
TOC = request.registry['documentation.toc']
|
||||
obj_ids = TOC.search(cr, uid, [], context=context)
|
||||
obj_ids = TOC.search(cr, uid, [('parent_id', '=', False)], context=context)
|
||||
toc_ids = TOC.browse(cr, uid, obj_ids, context=context)
|
||||
value = {
|
||||
'documentaion_toc': toc_ids,
|
||||
|
@ -45,14 +45,14 @@ class WebsiteForum(WebsiteForum):
|
|||
def prepare_question_values(self, forum, **kwargs):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
TOC = request.registry['documentation.toc']
|
||||
obj_ids = TOC.search(cr, uid, [], context=context)
|
||||
obj_ids = TOC.search(cr, uid, [('child_ids', '=', False)], context=context)
|
||||
toc = TOC.browse(cr, uid, obj_ids, context=context)
|
||||
values = super(WebsiteForum, self).prepare_question_values(forum=forum, kwargs=kwargs)
|
||||
values.update({'documentaion_toc': toc})
|
||||
return values
|
||||
|
||||
@http.route('/forum/question/toc', type='json', auth="user", multilang=True, website=True)
|
||||
def post_toc(self, post_id, toc_id):
|
||||
toc_id = int(toc_id) if toc_id else False
|
||||
request.registry['forum.post'].write(request.cr, request.uid, [int(post_id)], {'toc_id': toc_id}, context=request.context)
|
||||
return True
|
||||
@http.route('/forum/<model("forum.forum"):forum>/question/<model("forum.post"):post>/toc', type='http', auth="user", multilang=True, website=True)
|
||||
def post_toc(self, forum, post, **kwargs):
|
||||
toc_id = int(kwargs.get('content')) if kwargs.get('content') else False
|
||||
request.registry['forum.post'].write(request.cr, request.uid, [post.id], {'toc_id': toc_id}, context=request.context)
|
||||
return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post)))
|
|
@ -3,19 +3,64 @@
|
|||
<data>
|
||||
|
||||
<!-- Table Of Content -->
|
||||
<record id="toc_0" model="documentation.toc">
|
||||
<field name="name">CMS & eCommerce</field>
|
||||
<record id="toc_functional_doc" model="documentation.toc">
|
||||
<field name="name">Functional Documentation</field>
|
||||
</record>
|
||||
<record id="toc_1" model="documentation.toc">
|
||||
<record id="toc_sale" model="documentation.toc">
|
||||
<field name="name">Sales Management</field>
|
||||
<field name="parent_id" ref="toc_functional_doc"/>
|
||||
</record>
|
||||
<record id="toc_sale_customer" model="documentation.toc">
|
||||
<field name="name">Customers</field>
|
||||
<field name="parent_id" ref="toc_sale"/>
|
||||
</record>
|
||||
<record id="toc_sale_so" model="documentation.toc">
|
||||
<field name="name">Sales orders</field>
|
||||
<field name="parent_id" ref="toc_sale"/>
|
||||
</record>
|
||||
<record id="toc_0" model="documentation.toc">
|
||||
<field name="name">Sales & Warehouse</field>
|
||||
<field name="parent_id" ref="toc_sale"/>
|
||||
</record>
|
||||
<record id="toc_crm" model="documentation.toc">
|
||||
<field name="name">Customer Relationship Management</field>
|
||||
<field name="parent_id" ref="toc_functional_doc"/>
|
||||
</record>
|
||||
<record id="toc_crm_lead" model="documentation.toc">
|
||||
<field name="name">Lead & Opportunity</field>
|
||||
<field name="parent_id" ref="toc_crm"/>
|
||||
</record>
|
||||
<record id="toc_crm_claim" model="documentation.toc">
|
||||
<field name="name">Claims</field>
|
||||
<field name="parent_id" ref="toc_crm"/>
|
||||
</record>
|
||||
<record id="toc_crm_after_sale" model="documentation.toc">
|
||||
<field name="name">After-sale communication</field>
|
||||
<field name="parent_id" ref="toc_crm"/>
|
||||
</record>
|
||||
<record id="toc_website" model="documentation.toc">
|
||||
<field name="name">Website</field>
|
||||
<field name="parent_id" ref="toc_functional_doc"/>
|
||||
</record>
|
||||
<record id="toc_cms_ecommerce" model="documentation.toc">
|
||||
<field name="name">CMS & eCommerce</field>
|
||||
<field name="parent_id" ref="toc_website"/>
|
||||
</record>
|
||||
<record id="toc_hrm" model="documentation.toc">
|
||||
<field name="name">Human Resources Management</field>
|
||||
<field name="parent_id" ref="toc_functional_doc"/>
|
||||
</record>
|
||||
<record id="toc_hrm_contract" model="documentation.toc">
|
||||
<field name="name">Employee Contract</field>
|
||||
<field name="parent_id" ref="toc_hrm"/>
|
||||
</record>
|
||||
|
||||
<!-- Questions -->
|
||||
<record id="website_forum.question_0" model="forum.post">
|
||||
<field name="toc_id" ref="toc_1"/>
|
||||
<field name="toc_id" ref="toc_hrm_contract"/>
|
||||
</record>
|
||||
<record id="website_forum.question_1" model="forum.post">
|
||||
<field name="toc_id" ref="toc_0"/>
|
||||
<field name="toc_id" ref="toc_cms_ecommerce"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
|
|
@ -12,6 +12,8 @@ class Documentation(osv.Model):
|
|||
|
||||
_columns = {
|
||||
'name': fields.char('Name', required=True, translate=True),
|
||||
'parent_id': fields.many2one('documentation.toc', 'Parent Table Of Content'),
|
||||
'child_ids': fields.one2many('documentation.toc', 'parent_id', 'Children Table Of Content'),
|
||||
'post_ids': fields.one2many('forum.post', 'toc_id', 'Posts'),
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
|
@ -0,0 +1,20 @@
|
|||
.document {
|
||||
background: whitesmoke;
|
||||
padding-bottom: 1px;
|
||||
}
|
||||
|
||||
.document_page {
|
||||
background: white;
|
||||
overflow: hidden;
|
||||
-webkit-border-radius: 1px;
|
||||
-moz-border-radius: 1px;
|
||||
-ms-border-radius: 1px;
|
||||
-o-border-radius: 1px;
|
||||
border-radius: 1px;
|
||||
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
|
||||
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
.menu-tree li{
|
||||
padding: 0px 0px 0px 10px;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
.document
|
||||
background: whitesmoke
|
||||
padding-bottom: 1px
|
||||
|
||||
.document_page
|
||||
background: white
|
||||
overflow: hidden
|
||||
-webkit-border-radius: 1px
|
||||
-moz-border-radius: 1px
|
||||
-ms-border-radius: 1px
|
||||
-o-border-radius: 1px
|
||||
border-radius: 1px
|
||||
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35)
|
||||
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35)
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35)
|
||||
|
||||
.menu-tree li
|
||||
padding: 0px 0px 0px 10px
|
|
@ -1,12 +1,19 @@
|
|||
$(document).ready(function () {
|
||||
|
||||
$('.post_toc').change(function (ev) {
|
||||
var $option = $(ev.currentTarget);
|
||||
openerp.jsonRpc("/forum/question/toc", 'call', {
|
||||
'post_id' : $('#question').attr("value"),
|
||||
'toc_id': $option.attr("value"),
|
||||
})
|
||||
return true;
|
||||
$(function () {
|
||||
$('.menu-tree li li').hide();
|
||||
$('.menu-tree li .active').parents().find(' > ul > li').show();
|
||||
$('.menu-tree li').on('click', function (e) {
|
||||
var children = $(this).find(' > ul > li');
|
||||
if (children.is(":visible")) {
|
||||
children.hide('fast');
|
||||
$(this).attr('title', 'Expand this branch');
|
||||
} else {
|
||||
children.show('fast');
|
||||
$(this).attr('title', 'Collapse this branch');
|
||||
}
|
||||
e.stopPropagation();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -3,6 +3,18 @@
|
|||
<data>
|
||||
|
||||
<!-- DOCUMENTATION TOC VIEWS -->
|
||||
|
||||
<record id="view_documentation_toc_hierarchy" model="ir.ui.view">
|
||||
<field name="name">documentation.toc.list</field>
|
||||
<field name="model">documentation.toc</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Documentation TOC">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_documentation_toc_list" model="ir.ui.view">
|
||||
<field name="name">documentation.toc.list</field>
|
||||
<field name="model">documentation.toc</field>
|
||||
|
@ -21,22 +33,32 @@
|
|||
<sheet>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="parent_id"/>
|
||||
</group>
|
||||
<separator string="Posts"/>
|
||||
<field name="post_ids"/>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_documentation_toc" model="ir.actions.act_window">
|
||||
<field name="name">Documentation TOC</field>
|
||||
<field name="name">Documentation</field>
|
||||
<field name="res_model">documentation.toc</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_documentation" parent="website_forum.menu_website_forum" name="Documentation TOC" action="action_documentation_toc" sequence="10"/>
|
||||
<menuitem id="menu_documentation" parent="website_forum.menu_website_forum" name="Documentation" action="action_documentation_toc" sequence="20"/>
|
||||
|
||||
<record id="action_documentation_toc_hierarchy" model="ir.actions.act_window">
|
||||
<field name="name">Documentation Hierarchy</field>
|
||||
<field name="res_model">documentation.toc</field>
|
||||
<field name="view_type">tree</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="domain">[('parent_id','=',False)]</field>
|
||||
<field name="view_id" ref="view_documentation_toc_hierarchy"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_documentation_hierarchy" parent="website_forum.menu_website_forum" name="Documentation Hierarchy" action="action_documentation_toc_hierarchy" sequence="25"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -25,30 +25,19 @@
|
|||
<link rel='stylesheet' href='/website_doc/static/src/css/website_doc.css'/>
|
||||
<script type="text/javascript" src="/website_doc/static/src/js/website_doc.js"/>
|
||||
</t>
|
||||
<div class="container mt16">
|
||||
<div class="col-md-3 css_noprint bs-sidebar" id="left_column">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<t t-foreach="documentaion_toc" t-as="toc">
|
||||
<li t-att-class="topic == toc and 'active' or ''">
|
||||
<a t-attf-href="/doc/#{ slug(toc) }">
|
||||
<t t-esc="toc.name"/>
|
||||
<!--span class="badge pull-right" t-if="toc.post_ids"><t t-esc="toc.post_ids"/></span-->
|
||||
</a>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
<div class="container mt16 document">
|
||||
<div class="col-md-3 mt32 css_noprint bs-sidebar menu-tree">
|
||||
<t t-call="website_doc.side_panel"><t t-set="documentation" t-value="documentaion_toc"/></t>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div>
|
||||
<h2 t-esc="topic.name" class="text-center"/>
|
||||
</div>
|
||||
<div class="col-md-9 mt32 document_page">
|
||||
<strong><h2 t-esc="topic.name" class="text-center"/></strong>
|
||||
<div t-foreach="topic.post_ids" t-as="post">
|
||||
<h2><a class="faq-question"><t t-esc="post.name"/></a></h2>
|
||||
<h2><p class="faq-question" t-esc="post.name"/></h2>
|
||||
<div t-if="post.pertinent_answer_id">
|
||||
<p><t t-raw="post.pertinent_answer_id.content"/></p>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a class="" t-attf-href="/forum/#{ slug(post.forum_id) }/question/#{ slug(post) }">Read More About This..</a>
|
||||
<a t-attf-href="/forum/#{ slug(post.forum_id) }/question/#{ slug(post) }">Read More About This..</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -57,6 +46,25 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<!--MENU LIST-->
|
||||
<template id="side_panel">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<t t-foreach="documentation" t-as="toc">
|
||||
<li t-attf-class="tree_toggler #{ topic==toc and 'active' or ''}">
|
||||
<a t-attf-href="/doc/#{ slug(toc) }" t-if="not toc.child_ids">
|
||||
<t t-esc="toc.name"/>
|
||||
</a>
|
||||
<a t-attf-href="" t-if="toc.child_ids">
|
||||
<t t-esc="toc.name"/>
|
||||
</a>
|
||||
<t t-if="toc.child_ids">
|
||||
<t t-call="website_doc.side_panel"><t t-set="documentation" t-value="toc.child_ids"/></t>
|
||||
</t>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<!--TOC ON FORUM POST-->
|
||||
<template id="forum_question_right_column" inherit_id="website_forum.header" name="Table of Content">
|
||||
<xpath expr="//script[@src='/website_forum/static/src/js/website_forum.js']" position="after">
|
||||
|
@ -64,18 +72,24 @@
|
|||
</xpath>
|
||||
<xpath expr="//div[@id='about_forum']" position="before">
|
||||
<div t-if="header.get('question_data')">
|
||||
<span type="hidden" t-attf-value="#{question.id}" id="question"/>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" id="about_forum">
|
||||
<h3 class="panel-title">Documentation</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<select class="form-control post_toc" t-attf-href="/forum/#{ slug(forum) }/question/#{ question.id }/toc" name="Table of Content">
|
||||
<option value="">Table of Content...</option>
|
||||
<t t-foreach="documentaion_toc or []" t-as="toc">
|
||||
<option t-att-value="toc.id" t-att-selected="toc.id == question.toc_id.id"><t t-esc="toc.name"/></option>
|
||||
</t>
|
||||
</select>
|
||||
<form t-attf-action="/forum/#{ slug(forum) }/question/#{ slug(question) }/toc" role="form" method="post">
|
||||
<div class="input-group navbar-right">
|
||||
<select class="form-control" name="content">
|
||||
<option value=""></option>
|
||||
<t t-foreach="documentaion_toc or []" t-as="toc">
|
||||
<option t-att-value="toc.id" t-att-selected="toc.id == question.toc_id.id"><t t-esc="toc.name"/></option>
|
||||
</t>
|
||||
</select>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-primary ">save</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -90,8 +90,8 @@
|
|||
</div>
|
||||
<div class="col-sm-3" id="right-column">
|
||||
<a t-if="not header.get('ask_hide')" class="btn btn-primary btn-lg btn-block mb16" t-attf-href="/forum/#{slug(forum)}/ask">Ask a Question</a>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" id="about_forum">
|
||||
<div class="panel panel-default" id="about_forum">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">About This Forum</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
|
Loading…
Reference in New Issue