[IMP] web: Keep multi company config when switching company

when moving from company A to company B, company A should not be 'uncheck' (it should stay in the set of visible companies)
use case: https://drive.google.com/file/d/1o9lN_8jHSxDOkeqTpo7F_NgmvO4NwF2l/view
I start in A with only A visible
I check B to make both A and B visible
I move to B and A is not visible anymore
when moving to a company that is not checked, it should be checked, but the reverse is not true (moving out of a company should not uncheck it)

fp request
This commit is contained in:
Yannick Tivisse
2019-05-28 14:31:34 +00:00
parent 73474f56fa
commit ec670beb4b
@@ -57,9 +57,14 @@ var SwitchCompanyMenu = Widget.extend({
var hash = $.bbq.getState()
var allowed_company_ids = _.map(hash.cids.split(','), function(company_id) {return parseInt(company_id);});
if ($($(ev.currentTarget).parent()).find('.fa-square-o').length) {
allowed_company_ids.push(companyID);
// 1 enabled company: Stay in single company mode
if (this.allowed_company_ids.length === 1) {
allowed_company_ids = [companyID]
} else { // Multi company mode
allowed_company_ids.push(companyID);
}
}
session.setCompanies(companyID, [companyID]);
session.setCompanies(companyID, allowed_company_ids);
},
//--------------------------------------------------------------------------