-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.js
More file actions
121 lines (95 loc) · 4.02 KB
/
UI.js
File metadata and controls
121 lines (95 loc) · 4.02 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
114
115
116
117
118
119
120
121
function onOpen() {
const ui = SpreadsheetApp.getUi();
ui.createMenu('🚀 MET-Universal')
.addItem('📦 Process All Pending PDFs', 'processAllPDFs')
.addItem('🆕 Start New Month Sheet', 'createMonthlySheet')
.addSeparator()
.addSubMenu(ui.createMenu('⚙️ System Admin')
.addItem('🛠️ Run Initial Setup', 'createProjectFolders')
.addItem('🎯 Process Specific File', 'processSpecificFile') // Renamed here too
.addItem('🧹 Clean Active Sheet', 'resetActiveSheet'))
.addToUi();
}
/**
* UI MODULE: The Interior Designer.
*/
/**
* UI MODULE: The Interior Designer
* Bootstraps the professional template with Column A and Row 1 as "borders".
*/
function createMasterTemplate() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
let template = ss.getSheetByName("TEMPLATE_DO_NOT_DELETE");
if (!template) {
template = ss.insertSheet("TEMPLATE_DO_NOT_DELETE");
// --- ADD THIS SECTION ---
// 1. Set Column A (Border) to 25 pixels (1/4 of default 100)
template.setColumnWidth(1, 25);
// 2. Set Row 1 (Border) to a similar thin size
template.setRowHeight(1, 25);
// 3. Pro-Tip: Make Column C (Description) wider while we are at it
// Most bank descriptions are long, so 300-400px is usually better.
template.setColumnWidth(3, 350);
// 4. Set the rest to a clean standard (optional)
// [B:2, C:3, D:4, E:5, F:6, G:7]
template.setColumnWidth(2, 100); // Date
template.setColumnWidth(4, 100); // Amount
template.setColumnWidth(5, 150); // Category
template.setColumnWidth(6, 120); // Bank
// Update headers to include Latency
const headers = [["Date", "Description", "Amount", "Category", "Bank", "Confidence", "Tokens", "Latency"]];
// Update range to 1 row, 8 columns (B through I)
template.getRange(2, 2, 1, 8).setValues(headers);
// Update header styling to cover I2
template.getRange("B2:I2")
.setBackground("#3498db")
.setFontColor("#ffffff")
.setFontWeight("bold");
const headerRange = template.getRange("B2:I2");
headerRange.setValues(headers);
// 2. Header Styling: Light Blue background, Bold White text
headerRange
.setBackground("#3498db") // A clean, professional Light Blue
.setFontColor("#ffffff")
.setFontWeight("bold")
.setHorizontalAlignment("center")
.setVerticalAlignment("middle");
// 3. Set the "Borders" (A and 1) to a neutral Dark Grey
template.getRange("A:A").setBackground("#444444");
template.getRange("1:1").setBackground("#444444");
// 4. Alternating Row Colors (B3 downwards)
// We use a Conditional Format rule so it grows with your data
const dataRange = template.getRange("B3:I1000");
const rule = SpreadsheetApp.newConditionalFormatRule()
.whenFormulaSatisfied("=ISODD(ROW())")
.setBackground("#f4f4f4") // Light Grey for alternating rows
.setRanges([dataRange])
.build();
const rules = template.getConditionalFormatRules();
rules.push(rule);
template.setConditionalFormatRules(rules);
// 5. Freeze the UI borders and Headers
template.setFrozenRows(2);
template.setFrozenColumns(1);
template.hideSheet();
console.log("Master Template Styled: B2 Headers, A/1 Borders, Alternating Rows.");
}
}
/**
* UI MODULE: Utility
* Wipes the data but PROTECTS headers and blue styling.
*/
function resetActiveSheet() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getActiveSheet();
const lastRow = sheet.getLastRow();
// Safety check: Don't do anything if there's no data below headers
if (lastRow < 3) return;
// 1. Target B3 to G (Everything below the header)
// We use clearContent() so the background colors (zebra stripes) stay!
const dataRange = sheet.getRange(3, 2, lastRow - 2, 8);
dataRange.clearContent();
// 2. Optional: If you want to delete the actual rows to reset the scroll bar
sheet.deleteRows(3, lastRow - 2);
SpreadsheetApp.getUi().alert("🧹 Data cleared. Blue headers preserved!");
}