-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathImport_Settings.html
108 lines (91 loc) · 3.87 KB
/
Import_Settings.html
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
<!--
Author: Gaurav Grover ([email protected])
Date: 14/06/2016
Purpose: GUI for the "Import Setting" option in the custom menu
-->
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
#status-box {
background: #F9EDBE;
width: 100px;
border: 1px solid #f7c4be;
margin: auto;
text-align: center;
display: none;
}
input[name="submit"] {
background: #61B450;
color: white;
float: right;
}
</style>
</head>
<body>
<div class = "wrapper">
<div class="options">
<!-- "Name" attribute act as the header if the field and "data-value" stores json address of the corresponding field in comma seperated list -->
<label><input type="checkbox" name="id" data-value="id" checked> id</label><br>
<label><input type="checkbox" name="Order Number" data-value="order_number" checked> Order Number</label><br>
<label><input type="checkbox" name="Order Key" data-value="order_key" checked> Order Key</label><br>
<label><input type="checkbox" name="Status" data-value="status" checked> Status</label><br>
<label><input type="checkbox" name="Total" data-value="total" checked> Total</label><br>
<label><input type="checkbox" name="Total Tax" data-value="total_tax" checked> Total Tax</label><br>
<label><input type="checkbox" name="Customer First Name" data-value="billing_address,first_name" checked> Customer First Name</label><br>
<label><input type="checkbox" name="Customer Last Name" data-value="billing_address,last_name" checked> Customer Last Name</label><br>
<label><input type="checkbox" name="Total Line Items" data-value="total_line_items_quantity" checked> Total Line Items</label><br>
<label><input type="checkbox" name="Product Id" data-value="line_items,0,id" checked> Product id</label><br>
<label><input type="checkbox" name="Mode Of Payment" data-value="payment_details,method_title" checked> Mode of Payment</label><br>
<label><input type="checkbox" name="Paid" data-value="payment_details,paid" checked> Paid Or Not</label><br>
</div>
<div class="submit">
<input type="submit" name="submit" value="Save" onclick="send()">
<input type="submit" name="submit" value="Use Defaults" onclick="removeCustomSettings()">
</div>
</div><br><br>
<div id="status-box" >Processing...</div>
<script>
/**
* Displays loading status in the page itself
*/
function displayLoader() {
var el = document.getElementById('status-box');
el.style.display="block";
}
/**
* Success handler function for the google.script.run functions
*/
function onSuccess() {
google.script.host.close();
}
/**
* Sends configuration received from user to the setImportSettings() in Import.gs
*/
function send() {
displayLoader();
/* get array of input tags */
var options = [];
options = document.querySelectorAll(".options input");
/* iterate over fetched array and save the values in a new object for only checked inputs */
var obj = {};
var attrName, attrValue;
for(var i=0; i<12; ++i ) {
if(options[i].checked) {
attrName = options[i].getAttribute("name");
attrValue = options[i].getAttribute("data-value");
obj[attrName] = attrValue;
}
}
obj = JSON.stringify(obj);
google.script.run.withSuccessHandler(onSuccess).setImportSettings(obj);
}
function removeCustomSettings() {
displayLoader();
/* Remove Custom Import Properties */
google.script.run.withSuccessHandler(onSuccess).deleteUserOrdersImportSettings();
}
</script>
</body>
</html>