Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
erp5
Commits
7573a676
Commit
7573a676
authored
Apr 24, 2019
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_only_office] olap_wizard.js: filter used hierarchies instead used dimensions
parent
dc1f33e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
173 additions
and
49 deletions
+173
-49
bt5/erp5_only_office/SkinTemplateItem/portal_skins/erp5_only_office/onlyoffice.gadget.js.js
...tem/portal_skins/erp5_only_office/onlyoffice.gadget.js.js
+12
-0
bt5/erp5_only_office/SkinTemplateItem/portal_skins/erp5_only_office/onlyoffice/olap_wizard.js.js
...ortal_skins/erp5_only_office/onlyoffice/olap_wizard.js.js
+81
-49
bt5/erp5_only_office/SkinTemplateItem/portal_skins/erp5_only_office/onlyoffice/xmla_client.js.js
...ortal_skins/erp5_only_office/onlyoffice/xmla_client.js.js
+80
-0
No files found.
bt5/erp5_only_office/SkinTemplateItem/portal_skins/erp5_only_office/onlyoffice.gadget.js.js
View file @
7573a676
...
...
@@ -434,6 +434,18 @@ DocsAPI.DocEditor.version = function () {
console
.
error
(
err
);
});
})
.
allowPublicAcquisition
(
"
xmla_getDimension
"
,
function
(
arr
)
{
return
this
.
getDeclaredGadget
(
"
xmla_client
"
)
.
push
(
function
(
g
)
{
return
g
.
getDimension
(
arr
[
0
],
arr
[
1
]);
});
})
.
allowPublicAcquisition
(
"
xmla_getHierarchies
"
,
function
(
arr
)
{
return
this
.
getDeclaredGadget
(
"
xmla_client
"
)
.
push
(
function
(
g
)
{
return
g
.
getHierarchies
(
arr
[
0
],
arr
[
1
]);
});
})
// methods emulating Gateway used for connection with ooffice begin.
.
declareMethod
(
'
appReady
'
,
function
()
{
...
...
bt5/erp5_only_office/SkinTemplateItem/portal_skins/erp5_only_office/onlyoffice/olap_wizard.js.js
View file @
7573a676
...
...
@@ -4,19 +4,19 @@
(
function
(
window
,
rJS
)
{
"
use strict
"
;
function
get_used_
dimension
s
(
g
)
{
function
get_used_
hierarchie
s
(
g
)
{
return
g
.
getContent
()
.
push
(
function
(
v
)
{
var
dimension
s
=
[],
var
hierarchie
s
=
[],
key
,
dimension
;
hierarchy
;
if
(
v
)
{
if
(
v
.
columns
)
{
for
(
key
in
v
.
columns
)
{
if
(
v
.
columns
.
hasOwnProperty
(
key
))
{
dimension
=
v
.
columns
[
key
].
dimension
;
if
(
dimension
)
{
dimensions
.
push
(
dimension
);
hierarchy
=
v
.
columns
[
key
].
hierarchy
;
if
(
hierarchy
)
{
hierarchies
.
push
(
hierarchy
);
}
}
}
...
...
@@ -24,19 +24,45 @@
if
(
v
.
rows
)
{
for
(
key
in
v
.
rows
)
{
if
(
v
.
rows
.
hasOwnProperty
(
key
))
{
dimension
=
v
.
rows
[
key
].
dimension
;
if
(
dimension
)
{
dimensions
.
push
(
dimension
);
hierarchy
=
v
.
rows
[
key
].
hierarchy
;
if
(
hierarchy
)
{
hierarchies
.
push
(
hierarchy
);
}
}
}
}
}
return
dimension
s
;
return
hierarchie
s
;
});
}
function
discoverDimensions
(
g
,
connection_name
,
used_dimensions
)
{
return
g
.
request
(
"
discoverMDDimensions
"
,
connection_name
)
function
discoverDimensions
(
g
,
connection_name
,
used_hierarchies
)
{
return
g
.
getHierarchies
(
connection_name
)
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
error
);
})
.
push
(
function
(
response
)
{
var
dimensions
=
{},
i
,
row
,
uname
,
tasks
=
[];
for
(
i
=
0
;
i
<
response
.
length
;
i
+=
1
)
{
row
=
response
[
i
];
uname
=
row
.
DIMENSION_UNIQUE_NAME
;
if
(
!
dimensions
.
hasOwnProperty
(
uname
)
&&
used_hierarchies
.
indexOf
(
row
.
HIERARCHY_UNIQUE_NAME
)
<
0
&&
row
.
DIMENSION_TYPE
!==
2
// !measure
)
{
dimensions
[
uname
]
=
true
;
}
}
for
(
i
in
dimensions
)
{
if
(
dimensions
.
hasOwnProperty
(
i
))
{
tasks
.
push
(
g
.
getDimension
(
connection_name
,
i
))
}
}
return
RSVP
.
all
(
tasks
);
})
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
error
);
})
...
...
@@ -46,19 +72,16 @@
row
;
for
(
i
=
0
;
i
<
response
.
length
;
i
+=
1
)
{
row
=
response
[
i
];
if
(
row
[
"
DIMENSION_TYPE
"
]
!==
2
&&
used_dimensions
.
indexOf
(
row
[
"
DIMENSION_UNIQUE_NAME
"
])
<
0
)
{
arr
.
push
({
const
:
row
[
"
DIMENSION_UNIQUE_NAME
"
]
||
undefined
,
title
:
row
[
"
DIMENSION_NAME
"
]
||
undefined
});
}
arr
.
push
({
const
:
row
.
DIMENSION_UNIQUE_NAME
||
undefined
,
title
:
row
.
DIMENSION_NAME
||
undefined
});
}
return
arr
;
});
}
function
discoverHierarchies
(
g
,
connection_name
,
opt
)
{
function
discoverHierarchies
(
g
,
connection_name
,
used_hierarchies
,
opt
)
{
return
g
.
request
(
"
discoverMDHierarchies
"
,
connection_name
,
opt
)
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
error
);
...
...
@@ -66,13 +89,17 @@
.
push
(
function
(
response
)
{
var
arr
=
[],
i
,
row
;
row
,
uname
;
for
(
i
=
0
;
i
<
response
.
length
;
i
+=
1
)
{
row
=
response
[
i
];
arr
.
push
({
const
:
row
[
"
HIERARCHY_UNIQUE_NAME
"
]
||
undefined
,
title
:
row
[
"
HIERARCHY_NAME
"
]
||
undefined
});
uname
=
row
.
HIERARCHY_UNIQUE_NAME
;
if
(
used_hierarchies
.
indexOf
(
uname
)
<
0
)
{
arr
.
push
({
const
:
uname
||
undefined
,
title
:
row
.
HIERARCHY_NAME
||
undefined
});
}
}
return
arr
;
});
...
...
@@ -103,13 +130,13 @@
});
}
function
generateChoiceSchema
(
g
,
connection_name
,
used_
dimension
s
,
choice_settings
)
{
function
generateChoiceSchema
(
g
,
connection_name
,
used_
hierarchie
s
,
choice_settings
)
{
var
schema
=
{
"
type
"
:
"
object
"
,
"
additionalProperties
"
:
false
,
"
properties
"
:
{}
},
current_
dimension
;
current_
hierarchy
;
if
(
!
connection_name
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
...
...
@@ -119,25 +146,28 @@
if
(
!
choice_settings
)
{
choice_settings
=
{};
}
current_dimension
=
choice_settings
.
dimension
;
if
(
current_dimension
)
{
used_dimensions
=
used_dimensions
.
filter
(
function
(
d
)
{
return
d
!==
current_dimension
;
current_hierarchy
=
choice_settings
.
hierarchy
;
if
(
current_hierarchy
)
{
used_hierarchies
=
used_hierarchies
.
filter
(
function
(
h
)
{
return
h
!==
current_hierarchy
;
});
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
var
tasks
=
[
discoverDimensions
(
g
,
connection_name
,
used_
dimension
s
)];
var
tasks
=
[
discoverDimensions
(
g
,
connection_name
,
used_
hierarchie
s
)];
if
(
choice_settings
.
dimension
)
{
tasks
.
push
(
discoverHierarchies
(
g
,
connection_name
,{
prop
:
{
restrictions
:
{
DIMENSION_UNIQUE_NAME
:
choice_settings
.
dimension
}
}})
discoverHierarchies
(
g
,
connection_name
,
used_hierarchies
,
{
prop
:
{
restrictions
:
{
DIMENSION_UNIQUE_NAME
:
choice_settings
.
dimension
}
}})
);
}
if
(
choice_settings
.
hierarchy
)
{
...
...
@@ -187,6 +217,8 @@
})
.
declareAcquiredMethod
(
"
getRemoteSettings
"
,
"
getRemoteSettings
"
)
.
declareAcquiredMethod
(
"
request
"
,
"
xmla_request
"
)
.
declareAcquiredMethod
(
"
getDimension
"
,
"
xmla_getDimension
"
)
.
declareAcquiredMethod
(
"
getHierarchies
"
,
"
xmla_getHierarchies
"
)
.
declareAcquiredMethod
(
"
getLevels
"
,
"
xmla_getLevels
"
)
.
allowPublicAcquisition
(
"
notifyValid
"
,
function
(
arr
,
scope
)
{
})
...
...
@@ -222,7 +254,7 @@
scope
=
arr
[
0
].
scope
,
relPath
=
arr
[
0
].
rel_path
,
action
=
arr
[
0
].
action
,
used_
diemensions
,
used_
hierarchy
,
url
=
arr
[
0
].
ref
,
allRerender
,
y
;
...
...
@@ -230,10 +262,10 @@
function
rerender
(
sub_scope
)
{
var
queue
,
gadget_settings
;
if
(
!
used_
diemensions
)
{
queue
=
get_used_
dimension
s
(
g
)
if
(
!
used_
hierarchy
)
{
queue
=
get_used_
hierarchie
s
(
g
)
.
push
(
function
(
v
)
{
used_
diemensions
=
v
;
used_
hierarchy
=
v
;
});
}
else
{
queue
=
RSVP
.
Queue
();
...
...
@@ -242,7 +274,7 @@
function
rerender_once
(
connection_name
,
sub_gadget
)
{
return
sub_gadget
.
getContent
()
.
push
(
function
(
content
)
{
return
generateChoiceSchema
(
g
,
connection_name
,
used_
diemensions
,
content
);
return
generateChoiceSchema
(
g
,
connection_name
,
used_
hierarchy
,
content
);
})
.
push
(
function
(
schema
)
{
return
gadget_settings
.
rerender
({
...
...
@@ -270,7 +302,7 @@
return
rerender_once
(
connection_name
,
sub_gadget
)
.
push
(
function
(
changed
)
{
if
(
changed
&&
changed
.
length
>
0
)
{
if
(
changed
.
indexOf
(
'
/
dimension
'
)
>=
0
)
{
if
(
changed
.
indexOf
(
'
/
hierarchy
'
)
>=
0
)
{
return
allRerender
();
}
return
rerender_once
(
connection_name
,
sub_gadget
);
...
...
@@ -285,9 +317,9 @@
}
allRerender
=
function
()
{
return
get_used_
dimension
s
(
g
)
return
get_used_
hierarchie
s
(
g
)
.
push
(
function
(
v
)
{
used_
diemensions
=
v
;
used_
hierarchy
=
v
;
return
RSVP
.
all
(
g
.
props
.
choices
.
map
(
function
(
q
)
{
return
rerender
(
q
);
}));
...
...
@@ -314,7 +346,7 @@
g
.
props
.
choices
.
splice
(
y
,
1
);
return
allRerender
();
}
if
(
relPath
===
"
/
dimension
"
)
{
if
(
relPath
===
"
/
hierarchy
"
)
{
return
allRerender
();
}
return
rerender
(
s
)
...
...
@@ -353,8 +385,8 @@
.
push
(
function
()
{
return
RSVP
.
all
([
g
.
getContent
(
"
/connection_name
"
),
g
.
getContent
(
path
),
g
et_used_dimensions
(
g
)
g
et_used_hierarchies
(
g
),
g
.
getContent
(
path
)
]);
})
.
push
(
function
(
arr
)
{
...
...
bt5/erp5_only_office/SkinTemplateItem/portal_skins/erp5_only_office/onlyoffice/xmla_client.js.js
View file @
7573a676
...
...
@@ -16,6 +16,22 @@
return
cache
[
key
];
}
function
cached_queue
(
cache
,
key
,
func
)
{
if
(
cache
.
hasOwnProperty
(
key
))
{
return
getFromCache
(
cache
,
key
);
}
var
queue
=
func
()
.
push
(
undefined
,
function
(
err
)
{
delete
cache
[
key
];
console
.
error
(
err
);
})
.
push
(
function
(
value
)
{
cache
[
key
]
=
value
;
});
cache
[
key
]
=
queue
;
return
queue
;
}
function
xmla_request
(
func
,
prop
)
{
var
xmla
=
new
Xmla
({
async
:
true
});
prop
=
JSON
.
parse
(
JSON
.
stringify
(
prop
));
...
...
@@ -141,6 +157,7 @@
console
.
log
(
"
xmla_client
"
);
g
.
props
=
{
cache
:
{},
cache_flags
:
{},
connections
:
{}
};
})
...
...
@@ -179,10 +196,13 @@
delete
g
.
props
.
connections
[
key
];
if
(
m_dict
[
key
]
!==
null
)
{
g
.
props
.
cache
[
key
]
=
{
dimensions
:
{},
hierarchies
:
{},
members
:
{},
levels
:
{},
membersOnLevel
:
{}
};
g
.
props
.
cache_flags
[
key
]
=
{};
g
.
props
.
connections
[
key
]
=
JSON
.
parse
(
m_dict
[
key
]);
}
}
...
...
@@ -202,6 +222,66 @@
console
.
error
(
error
);
});
})
.
declareMethod
(
"
getDimension
"
,
function
(
connection_name
,
uname
)
{
var
g
=
this
;
return
cached_queue
(
g
.
props
.
cache
[
connection_name
].
dimensions
,
uname
,
function
()
{
return
request
(
g
,
"
discoverMDDimensions
"
,
{
prop
:
{
restrictions
:
{
DIMENSION_UNIQUE_NAME
:
uname
}
}
},
connection_name
)
.
push
(
function
(
r
)
{
if
(
r
.
rowCount
()
===
0
)
{
throw
new
Error
(
"
dimension
"
+
uname
+
"
not found
"
);
}
return
r
.
readAsObject
();
});
});
})
.
declareMethod
(
"
getHierarchies
"
,
function
(
connection_name
,
restrictions
)
{
var
g
=
this
,
arr
,
cache
=
g
.
props
.
cache
[
connection_name
].
hierarchies
,
key
;
if
(
!
restrictions
&&
g
.
props
.
cache_flags
[
connection_name
].
all_hierarchies
)
{
arr
=
[];
for
(
key
in
cache
)
{
if
(
cache
.
hasOwnProperty
(
key
))
{
arr
.
push
(
cache
[
key
]);
}
}
return
arr
;
}
return
request
(
g
,
"
discoverMDHierarchies
"
,
{
prop
:
{
restrictions
:
restrictions
}
},
connection_name
)
.
push
(
function
(
response
)
{
var
row
,
ret
=
[],
uname
;
if
(
response
&&
response
.
numRows
>
0
)
{
while
(
response
.
hasMoreRows
())
{
row
=
response
.
readAsObject
();
uname
=
row
.
HIERARCHY_UNIQUE_NAME
;
if
(
!
cache
.
hasOwnProperty
(
uname
))
{
cache
[
uname
]
=
row
;
}
ret
.
push
(
row
);
response
.
nextRow
();
}
}
if
(
!
restrictions
)
{
g
.
props
.
cache_flags
[
connection_name
].
all_hierarchies
=
true
;
}
return
ret
;
});
})
.
declareMethod
(
"
getLevel
"
,
function
(
connection_name
,
level_uname
)
{
var
g
=
this
,
cache
=
g
.
props
.
cache
[
connection_name
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment