94601c1f
Renato De Donato
trevieww multitable
|
1
2
3
4
5
6
7
|
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
<link rel="import" href="../tree-view-controllet/tree-view-controllet.html" />
<link rel="import" href="../multi-table-controllet/multi-table-controllet.html" />
|
94601c1f
Renato De Donato
trevieww multitable
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<dom-module id="tree-view-multi-table-controllet">
<style is="custom-style">
.div_container {
display: flex;
flex-direction: row;
}
#material_tree_view {
position: relative;
width: 25%;
min-width: 200px;
height: 100vh;
}
#material_multi_table {
position: relative;
width: 75%;
margin-left: 64px;
margin-top: 8px;
}
</style>
<template>
<div class="div_container">
<paper-material id="material_tree_view" elevation="5">
<tree-view-controllet id="tree_view" root-name={{rootName}} opened-path={{openedPath}} preselected-fields={{preselectedFields}}></tree-view-controllet>
</paper-material>
<paper-material id="material_multi_table" elevation="5">
<multi-table-controllet id="multi_table" data-url={{dataUrl}}></multi-table-controllet>
</paper-material>
</div>
</template>
<script>
Polymer({
is : 'tree-view-multi-table-controllet',
properties : {
rootName : {
type : String,
value : "root"
},
preselectedFields : {
type : Array,
value : []
},
openedPath : {
type : String,
value : undefined
},
dataUrl : {
type : String,
|
a31f0660
root
sevc-controllet i...
|
67
68
|
value : undefined,
observer : '_init'
|
94601c1f
Renato De Donato
trevieww multitable
|
69
70
71
72
73
74
75
76
77
|
}
},
listeners: {
'tree-view-controllet_selected-fields': '_updateSelectedFields'
},
ready : function() {
|
a31f0660
root
sevc-controllet i...
|
78
79
|
// if(this.dataUrl)
// this._init();
|
94601c1f
Renato De Donato
trevieww multitable
|
80
81
82
|
$(this.$.material_tree_view).perfectScrollbar();
$(this.$.material_multi_table).perfectScrollbar();
|
94601c1f
Renato De Donato
trevieww multitable
|
83
84
|
},
|
a31f0660
root
sevc-controllet i...
|
85
86
87
88
89
90
|
attached : function(){
this._resize();
var that = this;
window.addEventListener("resize", function() { that._resize(); });
},
|
94601c1f
Renato De Donato
trevieww multitable
|
91
92
93
94
95
96
97
98
|
getFields : function() {
return this.$.tree_view.getFields();
},
getFlatFields : function() {
return this.$.tree_view.getFlatFields();
},
|
a31f0660
root
sevc-controllet i...
|
99
100
|
_init : function() {
var tree = document.getElementById('tree_view');
|
4bf5f658
root
update tree map, ...
|
101
|
var that = this;
|
a31f0660
root
sevc-controllet i...
|
102
103
104
105
106
|
$.ajax({
url: this.dataUrl,
dataType: "json",
success: function(data){
|
29124159
root
ckan tree-view up...
|
107
|
that.rootName = "data"
|
4bf5f658
root
update tree map, ...
|
108
|
data = that._filterJson(data);
|
a31f0660
root
sevc-controllet i...
|
109
110
|
tree.setAttribute("json-data", JSON.stringify(data));
tree.selectedFields = [];
|
4bf5f658
root
update tree map, ...
|
111
|
that._updateSelectedFields();
|
a31f0660
root
sevc-controllet i...
|
112
113
114
|
tree.ready();
}
});
|
4bf5f658
root
update tree map, ...
|
115
|
|
707a1508
root
update data-table...
|
116
|
this.$.multi_table.ready();
|
4bf5f658
root
update tree map, ...
|
117
118
119
120
121
|
},
_filterJson : function(data){
console.log(data);
console.log(this.dataUrl);
|
4bf5f658
root
update tree map, ...
|
122
|
if(data.result != undefined && data.result.resource_id != undefined) {
|
29124159
root
ckan tree-view up...
|
123
124
|
this.rootName = "result,records"
return data.result.records;
|
4bf5f658
root
update tree map, ...
|
125
126
|
}
return data;
|
a31f0660
root
sevc-controllet i...
|
127
128
|
},
|
94601c1f
Renato De Donato
trevieww multitable
|
129
130
131
132
133
|
_updateSelectedFields : function() {
var fields = this.$.tree_view.getFields();
this.$.multi_table.setSelectedFields(fields);
},
|
a31f0660
root
sevc-controllet i...
|
134
135
136
137
138
139
|
_resize : function(){
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
h = h - 64; //height with page scroller
$("#material_tree_view").height(h);
}
|
94601c1f
Renato De Donato
trevieww multitable
|
140
141
142
143
144
|
});
</script>
</dom-module>
|