-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncProperties.html
More file actions
113 lines (92 loc) · 3.94 KB
/
Copy pathAsyncProperties.html
File metadata and controls
113 lines (92 loc) · 3.94 KB
1
2
3
4
5
6
7
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<script src="https://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="https://cdn.jsdelivr.net/select2/4.0.3/js/select2.min.js"></script>
<button onclick ="showWholeSpreadsheet()">Ïîêàçàòü âñ¸</button><button onclick ="runPropertySync()">Ñèíõðîíèçèðîâàòü àòðèáóòû</button><br>
<label for="typeSelectors">Òèï<br>
<select id="typeSelectors">
<option>Çàãðóçêà</option>
</select></label><br>
<button onclick ="filterByOption()">Îòôèëüòðîâàòü ïî òèïó è àòðèáóòàì</button><br>
<div id="propSelectors">
</div>
<button onclick ="google.script.run.filterByProperties(selectedProps)">Îòôèëüòðîâàòü ïî àòðèáóòàì</button><br>
<label for="propertySelector">Äîáàâèòü àòðèáóò<br>
<select id="propertySelector">
</select></label><br>
<button onclick ="reloadPropertyList()">Ïåðåçàãðóçèòü ñïèñîê àòðèáóòîâ</button><br>
<script>
$(document).ready(function() {
loadTypes();
});
function showWholeSpreadsheet() {
google.script.run.showAllColumns();
google.script.run.showAllRows();
};
function runPropertySync() {
google.script.run.updatePropertyOptions();
}
function reloadPropertyList() {
google.script.run.Writelog('Reloading property list...');
var currType = $('#typeSelectors').val();
google.script.run.lookupTypeColumn(currType);
$("#propSelectors").empty();
$("#propSelectors").append($('<label>Çàãðóæàþòñÿ àòðèáóòû...</label><br>'));
google.script.run.Writelog('Getting property list');
google.script.run.withSuccessHandler(updatePropCheckboxes)
.withFailureHandler(function(error) {Logger.log(error);})
.getPropertyList(currType);
google.script.run.withSuccessHandler(createPropOptions)
.getPropertyColumns();
};
function updatePropCheckboxes(props) {
google.script.run.Writelog('Updating property checkboxes');
selectedProps = props;
$("#propSelectors").empty();
for(var prop in props) {
var propDOM = $('<input type="checkbox" name="'+props[prop]+'">').val(props[prop]).prop('checked',true).on('change',onCheckboxChange);
$("#propSelectors").append(propDOM);
var propDOM = $('<label>'+props[prop]+'</label><br>');
$("#propSelectors").append(propDOM);
};
google.script.run.Writelog('Updated property checkboxes');
};
function onCheckboxChange() {
google.script.run.updateProperty($('#typeSelectors').val(), $(this).prop('name'), this.checked);
};
function loadTypes() {
google.script.run.withSuccessHandler(createTypeOptions)
.withFailureHandler(function(error) {Logger.log(error);})
.getTypeList();
};
function createTypeOptions(typeList) {
$("#typeSelectors").empty();
$('#typeSelectors').off('change',reloadPropertyList);
for(var i in typeList) {
var option = $('<option value="'+typeList[i]+'">'+typeList[i]+'</option>');
$("#typeSelectors").append(option);
}
$('#typeSelectors').on('change',reloadPropertyList);
reloadPropertyList();
};
function createPropOptions(propList) {
$('#propertySelector').off('change',onPropOptionChanged);
$('#propertySelector').empty();
for(var i=1;i<propList.length;i++) {
var option = $('<option value="'+propList[i]+'">'+propList[i]+'</option>');
$("#propertySelector").append(option);
}
$('#propertySelector').on('change',onPropOptionChanged);
};
function onPropOptionChanged() {
var propName = $(this).val();
var propDOM = $('<input type="checkbox" name="'+propName+'">').val(propName).prop('checked',true).on('change',onCheckboxChange);
$("#propSelectors").append(propDOM);
var propDOM = $('<label>'+propName+'</label><br>');
$("#propSelectors").append(propDOM);
google.script.run.updateProperty($('#typeSelectors').val(),propName, true);
};
function filterByOption() {
var type = $('#typeSelectors').val();
google.script.run.filterByParentType(type);
google.script.run.filterByProperties(selectedProps);
};
</script>