Skip to content

Commit 19ba137

Browse files
Bold Create Agentsuriyaprakasamr
andcommitted
Add Role column to permissions table and move it below the header
- Added the Role column (Price Editor, Reviewer, Commenter, Editor, Viewer) to the user permissions table - Moved the table to the toolbar area right after the sample header with a full-width layout - Cleaned up region marker comments and a redundant empty branch in app.ts Co-authored-by: suriyaprakasamr <302142999+suriyaprakasamr@users.noreply.github.com> Bold-Create-Session: https://app.boldcreate.ai/agent/chat/?threadId=12b07b78-1832-49fa-8f4a-31352769b404
1 parent 47f2eb6 commit 19ba137

3 files changed

Lines changed: 26 additions & 43 deletions

File tree

‎document-protection/src/app/app.ts‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ let currentUser: UserPermission = users[0];
7676

7777
documentEditor.open(JSON.stringify((<any>documentProtectionData)));
7878
applyUserPermissions(currentUser);
79-
// endregion
8079

81-
// region: User selection dropdown and permissions table
8280
const userSelect: HTMLSelectElement = document.getElementById('userSelect') as HTMLSelectElement;
8381
users.forEach(function (user: UserPermission): void {
8482
const option: HTMLOptionElement = document.createElement('option');
@@ -96,9 +94,7 @@ userSelect.addEventListener('change', function (): void {
9694
applyUserPermissions(currentUser);
9795
}
9896
});
99-
// endregion
10097

101-
// region: Apply per-user protection and restrictions
10298
/**
10399
* Enforces the document protection for the selected user.
104100
* The Document Editor checks `documentHelper.isDocumentProtected` along with
@@ -113,9 +109,7 @@ function applyUserPermissions(user: UserPermission): void {
113109
// Reset read-only restriction of the container (used for Laura)
114110
documentEditor.isReadOnly = false;
115111
documentEditor.currentUser = user.email;
116-
if (user.protectionType === 'NoProtection') {
117-
// Michael: full editing, no protection applied
118-
} else {
112+
if (user.protectionType !== 'NoProtection') {
119113
// Enforces ReadOnly, RevisionsOnly or CommentsOnly without a password
120114
documentEditor.editorModule.enforceProtection('', user.protectionType);
121115
}
@@ -128,9 +122,7 @@ function applyUserPermissions(user: UserPermission): void {
128122
documentEditor.documentHelper.restrictEditingPane.showHideRestrictPane(false);
129123
updatePermissionBanner(user);
130124
}
131-
// endregion
132125

133-
// region: Approval workflow - block accept/reject revisions for Andrew
134126
/**
135127
* Andrew works in `RevisionsOnly` protection: every edit is tracked, but the
136128
* built-in accept/reject actions are blocked, so a reviewer with approval
@@ -142,9 +134,7 @@ documentEditor.beforeAcceptRejectChanges = function (args: any): void {
142134
args.cancel = true;
143135
}
144136
};
145-
// endregion
146137

147-
// region: Export DOCX and PDF (Laura's permissions)
148138
/**
149139
* Exports the current document content as PDF through the online demo web
150140
* service `Export` action.
@@ -188,13 +178,10 @@ const exportPdfButton: HTMLButtonElement = document.getElementById('exportPdf')
188178
exportPdfButton.addEventListener('click', function (): void {
189179
formatSave('Pdf');
190180
});
191-
// endregion
192181

193-
// region: Permission details panel
194182
function updatePermissionBanner(user: UserPermission): void {
195183
const banner: HTMLElement | null = document.getElementById('permissionBanner');
196184
if (banner) {
197185
banner.textContent = 'Signed in as ' + user.name + ' (' + user.email + ') - ' + user.role;
198186
}
199-
}
200-
// endregion
187+
}

‎document-protection/src/index.html‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,57 +17,64 @@ <h1>User based restrict editing and approval workflow in JavaScript DOCX Editor<
1717
</p>
1818
</div>
1919
<div class="sample-toolbar">
20-
<label for="userSelect">Signed in user:</label>
21-
<select id="userSelect" title="Choose the user whose permissions are applied"></select>
22-
<span id="permissionBanner" class="permission-banner"></span>
23-
<span class="toolbar-spacer"></span>
24-
<button id="exportDocx" class="export-button" title="Export as Word document (*.docx)">Export as DOCX</button>
25-
<button id="exportPdf" class="export-button" title="Export as PDF">Export as PDF</button>
26-
</div>
27-
<div class="sample-content">
28-
<div class="editor-holder">
29-
<!-- Element which will render as Document Editor -->
30-
<div id="DocumentEditor"></div>
31-
</div>
3220
<div class="permission-holder">
33-
<h4>User permissions</h4>
3421
<table class="permission-table">
3522
<thead>
3623
<tr>
3724
<th>User</th>
25+
<th>Role</th>
3826
<th>Email</th>
3927
<th>Permissions</th>
4028
</tr>
4129
</thead>
4230
<tbody>
4331
<tr>
4432
<td>Nancy</td>
33+
<td>Price Editor</td>
4534
<td>nancy@example.com</td>
4635
<td>Can edit only the price values (marked editable ranges)</td>
4736
</tr>
4837
<tr>
4938
<td>Andrew</td>
39+
<td>Reviewer</td>
5040
<td>andrew@example.com</td>
5141
<td>All edits are tracked; cannot accept/reject revisions</td>
5242
</tr>
5343
<tr>
5444
<td>Steven</td>
45+
<td>Commenter</td>
5546
<td>steven@example.com</td>
5647
<td>Can insert comments only; cannot edit content</td>
5748
</tr>
5849
<tr>
5950
<td>Michael</td>
51+
<td>Editor</td>
6052
<td>michael@example.com</td>
6153
<td>Full editing (approves the tracked changes)</td>
6254
</tr>
6355
<tr>
6456
<td>Laura</td>
57+
<td>Viewer</td>
6558
<td>laura@example.com</td>
6659
<td>Read-only; can export as DOCX and PDF only</td>
6760
</tr>
6861
</tbody>
6962
</table>
7063
</div>
7164
</div>
65+
<div class="sample-toolbar">
66+
<label for="userSelect">Signed in user:</label>
67+
<select id="userSelect" title="Choose the user whose permissions are applied"></select>
68+
<span id="permissionBanner" class="permission-banner"></span>
69+
<span class="toolbar-spacer"></span>
70+
<button id="exportDocx" class="export-button" title="Export as Word document (*.docx)">Export as DOCX</button>
71+
<button id="exportPdf" class="export-button" title="Export as PDF">Export as PDF</button>
72+
</div>
73+
<div class="sample-content">
74+
<div class="editor-holder">
75+
<!-- Element which will render as Document Editor -->
76+
<div id="DocumentEditor"></div>
77+
</div>
78+
</div>
7279
</body>
7380
</html>

‎document-protection/src/styles/styles.css‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,8 @@ body {
8585
}
8686

8787
.permission-holder {
88-
width: 320px;
89-
padding: 16px;
90-
background-color: #ffffff;
91-
border-left: 1px solid #e0e0e0;
92-
min-height: 560px;
93-
box-sizing: border-box;
94-
}
95-
96-
.permission-holder h4 {
97-
margin: 0 0 12px;
98-
font-size: 15px;
99-
font-weight: 600;
100-
color: #1a202c;
88+
flex: 1;
89+
padding: 0;
10190
}
10291

10392
.permission-table {
@@ -108,7 +97,7 @@ body {
10897

10998
.permission-table th,
11099
.permission-table td {
111-
padding: 8px 6px;
100+
padding: 6px 8px;
112101
border: 1px solid #e0e0e0;
113102
text-align: left;
114103
vertical-align: top;
@@ -120,6 +109,6 @@ body {
120109
color: #1a202c;
121110
}
122111

123-
.permission-table td:nth-child(2) {
112+
.permission-table td:nth-child(3) {
124113
word-break: break-all;
125114
}

0 commit comments

Comments
 (0)