documentation/static/js/accounts.js
Antoine Vandevenne (anv) e3fee2cf46 [REF][MOV] documentation apocalypse
Prior to this commit, the Odoo documentation was mainly split between
two repositories: odoo/odoo/doc and odoo/documentation-user. Some bits
of documentation were also hosted elsewhere (e.g., wiki, upgrade, ...).
This was causing several problems among which:
  - The theme, config, Makefile, and similar technical resources had to
    be duplicated. This resulted in inconsistent layout, features, and
    build environments from one documentation to another.
  - Some pages did not fit either documentation as they were relevant
    for both users and developers. Some were relevant to neither of the
    two (e.g., DB management).
  - Cross-doc references had to be absolute links and they broke often.
  - Merging large image files in the developer documentation would bloat
    the odoo/odoo repository. Some contributions had to be lightened to
    avoid merging too many images (e.g., Odoo development tutorials).
  - Long-time contributors to the user documentation were chilly about
    going through the merging process of the developer documentation
    because of the runbot, mergebot, `odoo-dev` repository, etc.
  - Some contributors would look for the developer documentation in the
    `odoo/documentation-user` repository.
  - Community issues about the user documentation were submitted on the
    `odoo/odoo` repository and vice-versa.

Merging all documentations in one repository will allow us to have one
place, one theme, one work process, and one set of tools (build
environment, ...) for all of the Odoo docs.

As this is a good opportunity to revamp the layout of the documentation,
a brand new theme replaces the old one. It features a new way to
navigate the documentation, centered on the idea of always letting the
reader know what is the context (enclosing section, child pages, page
structure ...) of the page they are reading. The previous theme would
quickly confuse readers as they navigated the documentation and followed
cross-application links.

The chance is also taken to get rid of all the technical dangling parts,
performance issues, and left-overs. Except for some page-specific JS
scripts, the Odoo theme Sphinx extension is re-written from scratch
based on the latest Sphinx release to benefit from the improvements and
ease future contributions.

task-2351938
task-2352371
task-2205684
task-2352544

Closes #945
2021-05-04 15:44:00 +02:00

176 lines
7.6 KiB
JavaScript

/* global Immutable, React */
(function () {
// NOTE: used by memento.rst
'use strict';
function highlight(primary, secondary) {
return {
className: React.addons.classSet({
related: primary,
secondary: secondary
})
};
}
var AccountsTable = React.createClass({
render: function () {
return React.DOM.div(
{ style: { marginTop: '0' } },
React.DOM.div(// P&L
highlight(this.props.current === 'p-l'),
React.DOM.h4(null, "Profit & Loss"),
React.DOM.div(
null,
React.DOM.h5(
highlight(null, this.props.current === 'retained'),
"Net Profit"),
React.DOM.div(
highlight(null, this.props.current === 'gross-profit'),
React.DOM.h5(
highlight(this.props.current === 'gross-profit'),
"Gross Profit"),
React.DOM.dl(
null,
React.DOM.dt(null, "Revenue"),
React.DOM.dd(
null,
"Revenue"
),
React.DOM.dt(null, "Less ", "Costs of Revenue"),
React.DOM.dd(
null,
"Cost of Goods Sold"
)
)
),
React.DOM.div(
highlight(this.props.current === 'opex'),
React.DOM.h5(null, "Operating Income or Loss"),
React.DOM.dl(
null,
React.DOM.dt(
null,
"Less ", "Operating Expenses"),
React.DOM.dd(
null,
"R&D", React.DOM.br(),
"Sales, General & Administrative"
)
)
),
React.DOM.dl(
null,
React.DOM.dt(null, "Plus ", "Other Income"),
React.DOM.dd(
null,
"Foreign Exchange Gains", React.DOM.br(),
"Asset write-downs"
),
React.DOM.dt(
null,
"Less ", "Other Expenses"),
React.DOM.dd(
null,
"Interest on debt", React.DOM.br(),
"Depreciation"
)
)
)
),
React.DOM.div(//Balance Sheet
highlight(this.props.current === 'balance'),
React.DOM.h4(null, "Balance Sheet"),
React.DOM.div(
null,
React.DOM.h5(null, "Net Assets"),
React.DOM.div(
null,
React.DOM.h5(highlight(this.props.current === 'assets'), "Total Assets"),
React.DOM.dl(
highlight(null, this.props.current === 'assets'),
React.DOM.dt(null, "Current Assets"),
React.DOM.dd(
null,
"Cash & Bank Accounts", React.DOM.br(),
"Accounts Receivable", React.DOM.br(),
"Deferred Tax Assets"
),
React.DOM.dt(null, "Plus ", "Non-current Assets"),
React.DOM.dd(
null,
"Land & buildings", React.DOM.br(),
"Intangible Assets"
)
)
),
React.DOM.dl(
highlight(this.props.current === 'liabilities'),
React.DOM.dt(null, "Less ", "Current Liabilities"),
React.DOM.dd(
null,
"Accounts Payable", React.DOM.br(),
"Deferred Revenue", React.DOM.br(),
"Deferred Tax Liabilities"),
React.DOM.dt(null, "Less ", "Non-current liabilities"),
React.DOM.dd(
null,
"Long-term loans")
)
),
React.DOM.div(
highlight(null, this.props.current === 'equity'),
React.DOM.h5(highlight(this.props.current === 'equity'), "Total Equity"),
React.DOM.dl(
null,
React.DOM.dt(null, "Equity"),
React.DOM.dd(
null,
"Common Stock"
),
React.DOM.dt(
highlight(this.props.current === 'retained'),
"Plus ", "Retained Earnings"
)
)
)
)
);
}
});
document.addEventListener('DOMContentLoaded', function () {
var target = document.querySelector('.accounts-table');
if (!target) { return; }
function render(current) {
React.render(
React.createElement(AccountsTable, { current: current }),
target);
}
var list = document.querySelectorAll('.intro-list p');
Array.prototype.forEach.call(list, function (node) {
node.addEventListener('mouseover', function (e) {
if (!e.currentTarget.contains(e.target)) { return; }
e.currentTarget.classList.add('secondary');
render(e.currentTarget.className.split(/\s+/).reduce(function (acc, cls) {
if (acc) { return acc; }
var m = /^intro-(.*)$/.exec(cls);
return m && m[1];
}, null));
});
node.addEventListener('mouseout', function (e) {
// mouseout always precedes mousenter even when going into a
// child element. Since re-render should be pretty fast (just
// setting or unsetting a pair of classes) don't try to avoid
// any thrashing, things should be fast enough either way. If
// they're not, batch operations on requestAnimationFrame
// instead.
e.currentTarget.classList.remove('secondary');
render(null);
});
});
render(null);
});
})();