diff --git a/backend/asset-export-browser.test.js b/backend/asset-export-browser.test.js index 71843c9..19bb451 100644 --- a/backend/asset-export-browser.test.js +++ b/backend/asset-export-browser.test.js @@ -37,7 +37,7 @@ class Browser { } } -test('Chrome submits project export proposals, approves/rejects, isolates creators and displays saved files on desktop/mobile', { +test('Chrome preserves project export proposals and supports immediate manager exports for others on desktop/mobile', { skip: process.env.ACCMANAGER_EXPORT_BROWSER_TEST !== '1' ? 'Set ACCMANAGER_EXPORT_BROWSER_TEST=1 for isolated Chrome and SQL checks' : false, timeout: 120000 }, async () => { @@ -49,6 +49,9 @@ test('Chrome submits project export proposals, approves/rejects, isolates creato f.app.get('/api/asset-projects', (_req, res) => res.json({ success: true, data: [ { ProjectId: 1, ProjectName: 'Dự án A' }, { ProjectId: 2, ProjectName: 'Dự án B' } ] })); + f.app.get('/api/users', (_req, res) => res.json({ success: true, data: [ + { UserId: 1, FullName: 'Nguyễn An' }, { UserId: 2, FullName: 'Trần Bình' }, { UserId: 3, FullName: 'Quản lý kho' } + ] })); f.app.use('/api', (_req, res) => res.json({ success: true, data: [], unreadCount: 0, pagination: { total: 0, totalPages: 1 } })); f.app.get('/test-xlsx.js', (_req, res) => res.sendFile(require.resolve('xlsx/dist/xlsx.full.min.js'))); f.app.get('/test-notiflix.js', (_req, res) => res.type('js').send('window.Notiflix={Notify:{init(){},success(){},failure(){},warning(){}}};')); @@ -71,6 +74,7 @@ test('Chrome submits project export proposals, approves/rejects, isolates creato await client.send('Emulation.setDeviceMetricsOverride', { width: 1600, height: 1050, deviceScaleFactor: 1, mobile: false }); await client.send('Page.navigate', { url: `${f.origin}/pages/index.html#assets` }); await client.until('typeof app !== "undefined" && app?.assets?.length === 3 && !!document.getElementById("borrowAssetBtn")'); + assert.equal(await client.evaluate('!!document.getElementById("exportAssetForOthersBtn")'), false); await client.evaluate(`document.querySelector('.asset-row-checkbox[data-asset-id="1"]').click(); document.getElementById('borrowAssetBtn').click()`); await client.until('document.getElementById("borrowAssetModal").classList.contains("open")'); assert.equal(await client.evaluate('document.getElementById("borrowAssetUserInput").value'), 'Nguyễn An'); @@ -122,7 +126,57 @@ test('Chrome submits project export proposals, approves/rejects, isolates creato await client.send('Page.reload'); await client.until('typeof app !== "undefined" && app?.currentUser?.UserId === 2 && !app.assetExportLoading && !!document.getElementById("assetExportsTableBody")'); assert.equal(await client.evaluate('app.assetExportRequests.length'), 0); + assert.equal(await client.evaluate('!!document.getElementById("createAssetExportForOthersBtn")'), false); + // The additional manager action exports immediately; the proposal action remains available. + await client.send('Network.setExtraHTTPHeaders', { headers: { 'x-test-user': '3', 'x-test-role': 'admin' } }); + await client.send('Page.reload'); + await client.until('typeof app !== "undefined" && app?.currentUser?.Role === "admin" && !!document.getElementById("createAssetExportForOthersBtn")'); + await client.evaluate('document.getElementById("createAssetExportForOthersBtn").click()'); + await client.until('typeof app !== "undefined" && app?.currentUser?.Role === "admin" && app.assets.length === 3 && !!document.getElementById("exportAssetForOthersBtn")'); + await client.evaluate(`app.downloadBlobFile=(blob,name)=>{window.savedDownload={size:blob.size,name}}; document.querySelector('.asset-row-checkbox[data-asset-id="1"]').click(); document.getElementById('exportAssetForOthersBtn').click()`); + await client.until('document.getElementById("borrowAssetModal").classList.contains("open")'); + assert.equal(await client.evaluate('document.getElementById("borrowAssetRecipientInput").required'), true); + assert.equal(await client.evaluate('document.getElementById("borrowAssetRequesterField").hidden'), true); + await client.evaluate('document.getElementById("borrowAssetRecipientInput").value="Trần Bình"; document.getElementById("borrowAssetProjectInput").value="Dự án A"; const quantity=document.getElementById("borrowQuantityInput"); quantity.value="2"; quantity.dispatchEvent(new Event("input",{bubbles:true})); document.querySelector("#borrowAssetForm button[type=submit]").scrollIntoView({block:"nearest"})'); + await delay(250); + assert.equal(await client.evaluate('document.querySelector("#borrowAssetForm button[type=submit]").getBoundingClientRect().bottom <= innerHeight'), true); + assert.equal(await client.evaluate('document.documentElement.scrollWidth <= innerWidth + 1'), true); + await client.send('Page.captureScreenshot', { format: 'png' }).then(result => fs.writeFileSync(path.join(output, 'export-for-others-mobile.png'), Buffer.from(result.data, 'base64'))); + await client.evaluate('document.getElementById("borrowAssetForm").requestSubmit()'); + await client.until('!app.assetExportSubmitting && app.assets.find(row=>row.AssetId===1).EndingBalance===7 && window.savedDownload?.size>1000'); + assert.equal((await f.pool.request().query('SELECT COUNT(*) AS total FROM AssetExportRequests')).recordset[0].total, 2); + assert.equal(await client.evaluate('location.hash'), '#assets'); + await client.evaluate(`app.closeModals(); document.querySelector('.asset-row-checkbox[data-asset-id="1"]').click(); document.getElementById('borrowAssetBtn').click()`); + await client.until('document.getElementById("borrowAssetModal").classList.contains("open")'); + assert.equal(await client.evaluate('document.getElementById("borrowAssetForm").dataset.exportForOthers'), 'false'); + assert.equal(await client.evaluate('document.getElementById("borrowAssetRecipientInput").disabled'), true); + assert.equal(await client.evaluate('document.querySelector("#borrowAssetForm button[type=submit]").textContent'), 'Gửi đơn chờ duyệt'); + // The asset role can export multiple items for a recipient in one saved document. + await client.send('Network.setExtraHTTPHeaders', { headers: { 'x-test-user': '3', 'x-test-role': 'asset' } }); + await client.send('Page.reload'); + await client.until('typeof app !== "undefined" && app?.currentUser?.Role === "asset" && app.assets.length === 3 && !!document.getElementById("exportAssetForOthersBtn")'); + await client.send('Emulation.setDeviceMetricsOverride', { width: 1600, height: 1050, deviceScaleFactor: 1, mobile: false }); + await client.evaluate(`app.downloadBlobFile=(blob,name)=>{window.savedDownload={size:blob.size,name}}; document.querySelector('.asset-row-checkbox[data-asset-id="1"]').click(); document.querySelector('.asset-row-checkbox[data-asset-id="2"]').click(); document.getElementById('exportAssetForOthersBtn').click()`); + await client.until('document.getElementById("batchAssetExportModal").classList.contains("open")'); + await client.evaluate('document.getElementById("batchAssetExportRecipientInput").value="Nguyễn An"; const common=document.getElementById("batchAssetExportCommonProject"); common.value="Dự án B"; common.dispatchEvent(new Event("change"))'); + await client.send('Page.captureScreenshot', { format: 'png' }).then(result => fs.writeFileSync(path.join(output, 'batch-export-for-others.png'), Buffer.from(result.data, 'base64'))); + await client.evaluate('document.getElementById("batchAssetExportForm").requestSubmit()'); + await client.until('!app.assetExportSubmitting && app.assets.find(row=>row.AssetId===1).EndingBalance===6 && window.savedDownload?.size>1000'); + assert.equal((await f.pool.request().query('SELECT EndingBalance FROM AssetInventory WHERE AssetId = 2')).recordset[0].EndingBalance, 3); + assert.equal((await f.pool.request().query('SELECT COUNT(*) AS total FROM AssetExportRequests')).recordset[0].total, 2); + const saved = (await f.pool.request().query('SELECT SnapshotJson FROM AssetExportDocuments ORDER BY ExportedDate DESC')).recordset; + assert.equal(JSON.parse(saved[0].SnapshotJson).requesterName, 'Nguyễn An'); + assert.equal(JSON.parse(saved[1].SnapshotJson).requesterName, 'Trần Bình'); + await client.evaluate(`app.closeModals(); document.querySelector('.asset-row-checkbox[data-asset-id="1"]').click(); document.querySelector('.asset-row-checkbox[data-asset-id="2"]').click(); document.getElementById('borrowAssetBtn').click()`); + await client.until('document.getElementById("batchAssetExportModal").classList.contains("open")'); + assert.equal(await client.evaluate('document.getElementById("batchAssetExportForm").dataset.exportForOthers'), 'false'); + assert.equal(await client.evaluate('document.getElementById("batchAssetExportRecipientInput").disabled'), true); assert.deepEqual(client.errors, []); + } catch (err) { + if (client) console.error('Browser failure state:', await client.evaluate(`({ url: location.href, + role: typeof app !== 'undefined' && app?.currentUser?.Role, page: typeof app !== 'undefined' && app?.currentPage, + assets: typeof app !== 'undefined' && app?.assets?.length, errors: document.body.innerText.slice(-500) })`), client.errors); + throw err; } finally { if (client) client.socket.close(); chrome.kill(); diff --git a/backend/asset-export-requests-sql.test.js b/backend/asset-export-requests-sql.test.js index 39e41af..c012c80 100644 --- a/backend/asset-export-requests-sql.test.js +++ b/backend/asset-export-requests-sql.test.js @@ -1,8 +1,54 @@ const test = require('node:test'); const assert = require('node:assert/strict'); +const sql = require('mssql'); const XLSX = require('xlsx'); const { createExportSqlFixture } = require('./asset-export-sql-fixture'); +test('managers export for another recipient immediately while pending proposals remain separate', { + skip: process.env.ACCMANAGER_EXPORT_SQL_TEST !== '1' ? 'Set ACCMANAGER_EXPORT_SQL_TEST=1 for a disposable database' : false, + timeout: 120000 +}, async () => { + const f = await createExportSqlFixture(); + try { + const allocations = [{ projectName: 'Dự án A', quantity: 2 }, { projectName: 'Dự án B', quantity: 1 }]; + const stock = async id => (await f.pool.request().input('id', sql.Int, id) + .query('SELECT EndingBalance, Borrower FROM AssetInventory WHERE AssetId = @id')).recordset[0]; + const payload = { borrowerName: 'Trần Bình', allocations, note: 'Cấp cho người khác' }; + for (const endpoint of ['/assets/1/export', '/assets/export']) { + assert.equal((await f.request(endpoint, { method: 'POST', body: payload })).status, 403); + } + const pending = await f.request('/asset-export-requests', { user: 3, role: 'admin', method: 'POST', body: { + borrowerName: 'Trần Bình', items: [{ assetId: 1, allocations }] + } }); + assert.equal(pending.data.RequestStatus, 'pending'); assert.equal(pending.data.RequesterName, 'Quản lý kho'); + assert.equal((await stock(1)).EndingBalance, 10); + const single = await f.request('/assets/1/export', { user: 3, role: 'admin', method: 'POST', body: payload }); + assert.equal(single.status, 200); assert.equal(single.data.length, 2); + assert.equal((await stock(1)).EndingBalance, 7); assert.equal((await stock(1)).Borrower, null); + const document = await f.request(`/asset-export-documents/${single.document.documentId}`, { user: 3, role: 'admin' }); + assert.equal(document.data.snapshot.borrowerName, 'Trần Bình'); + assert.equal(document.data.snapshot.exportedByName, 'Quản lý kho'); + const download = await f.request(`/asset-export-documents/${single.document.documentId}/download`, { user: 3, role: 'admin' }); + assert.deepEqual(download.buffer, Buffer.from(single.document.contentBase64, 'base64')); + assert.ok(XLSX.read(download.buffer).Sheets.ycxvt); + const batch = await f.request('/assets/export', { user: 3, role: 'asset', method: 'POST', body: { + borrowerName: 'Nguyễn An', items: [{ assetId: 1, projectName: 'Dự án B', quantity: 1 }, + { assetId: 2, projectName: 'Dự án A', quantity: 2 }] + } }); + assert.equal(batch.status, 200); assert.equal(batch.data.length, 2); + assert.equal((await stock(1)).EndingBalance, 6); assert.equal((await stock(2)).EndingBalance, 3); + const requests = await f.request('/asset-export-requests', { user: 3, role: 'asset' }); + assert.equal(requests.data.length, 1); assert.equal(requests.data[0].RequestStatus, 'pending'); + const failed = await f.request('/assets/export', { user: 3, role: 'asset', method: 'POST', body: { + borrowerName: 'Trần Bình', items: [{ assetId: 1, projectName: 'A', quantity: 1 }, + { assetId: 2, projectName: 'A', quantity: 100 }] + } }); + assert.equal(failed.status, 400); + assert.equal((await stock(1)).EndingBalance, 6); assert.equal((await stock(2)).EndingBalance, 3); + assert.equal((await f.pool.request().query('SELECT COUNT(*) AS total FROM AssetExportDocuments')).recordset[0].total, 2); + } finally { await f.cleanup(); } +}); + test('SQL project export approvals preserve stock, ownership, documents, return isolation and concurrent decisions', { skip: process.env.ACCMANAGER_EXPORT_SQL_TEST !== '1' ? 'Set ACCMANAGER_EXPORT_SQL_TEST=1 for a disposable database' : false, timeout: 120000 diff --git a/backend/asset-export-ui.test.js b/backend/asset-export-ui.test.js index 500892c..a38dcec 100644 --- a/backend/asset-export-ui.test.js +++ b/backend/asset-export-ui.test.js @@ -6,20 +6,26 @@ const vm = require('node:vm'); function fixture() { const nodes = { borrowAssetIdInput: { value: '1' }, borrowAssetUserInput: { value: 'An' }, - borrowAssetProjectInput: { value: 'Dự án A' }, borrowQuantityInput: { value: '2' }, borrowAssetNoteInput: { value: '' } }; - const requests = [], messages = []; + borrowAssetProjectInput: { value: 'Dự án A' }, borrowQuantityInput: { value: '2' }, borrowAssetNoteInput: { value: '' }, + borrowAssetForm: { dataset: {} }, borrowAssetRecipientInput: { value: 'Bình' }, + batchAssetExportForm: { dataset: {} }, batchAssetExportUserInput: { value: 'An' }, + batchAssetExportRecipientInput: { value: 'Bình' }, batchAssetExportNoteInput: { value: '' } }; + const requests = [], messages = [], documents = [], refreshes = []; const button = { disabled: false }; const sandbox = { document: { addEventListener() {}, getElementById: id => nodes[id], querySelector: () => button, querySelectorAll: () => [] }, window: {}, location: { hash: '#assets' }, console, - fetch: async (url, options) => { requests.push({ url, options }); return { ok: true, json: async () => ({ success: true, data: { RequestStatus: 'pending' } }) }; } }; + fetch: async (url, options) => { requests.push({ url, options }); return { ok: true, json: async () => ({ + success: true, data: { RequestStatus: 'pending' }, document: { fileName: 'phieu-xuat.xlsx', contentBase64: 'ZmlsZQ==' } + }) }; } }; sandbox.window.fetch = sandbox.fetch; vm.runInNewContext(`${fs.readFileSync(path.join(__dirname, '../public/js/app.js'), 'utf8')}\napp = Object.create(AccountManager.prototype); globalThis.manager = app;`, sandbox); const manager = sandbox.manager; Object.assign(manager, { currentUser: { UserId: 1, Role: 'user', FullName: 'An' }, apiBase: '/api', selectedAssetIds: new Set([1]), assets: [{ AssetId: 1, AssetCode: 'TS-001', Quantity: 5, ExportInPeriod: 0, EndingBalance: 5 }], notifySuccess: message => messages.push(message), notifyFailure: message => messages.push(message), notifyWarning: message => messages.push(message), + showExportRequestDocument: file => documents.push(file), refreshAssetsUI: async () => refreshes.push('assets'), closeModals() {} }); - return { manager, sandbox, requests, messages, nodes, button }; + return { manager, sandbox, requests, messages, nodes, button, documents, refreshes }; } test('ordinary users submit existing project allocations as pending proposals without downloading or changing stock', async () => { @@ -71,3 +77,80 @@ test('ordinary users cannot invoke the proposal decision UI', async () => { await f.manager.processAssetExportRequest(1, 'approved', ''); assert.equal(f.requests.length, 0); }); + +test('admin and asset keep the existing single and batch pending proposal flows', async () => { + for (const role of ['user', 'admin', 'asset']) { + for (const batch of [false, true]) { + const f = fixture(); f.manager.currentUser.Role = role; + f.manager.collectBatchAssetExportItems = () => [{ assetId: 1, allocations: [{ projectName: 'Dự án A', quantity: 2 }] }]; + await f.manager[batch ? 'handleBatchAssetExportSubmit' : 'handleBorrowAssetSubmit']({ preventDefault() {} }); + assert.equal(f.requests[0].url, '/api/asset-export-requests'); + assert.equal(f.documents.length, 0); assert.equal(f.refreshes.length, 0); + assert.match(f.messages[0], /chờ admin\/asset duyệt/); + } + } +}); + +test('admin and asset can export selected assets to another recipient and download immediately', async () => { + for (const role of ['admin', 'asset']) { + for (const batch of [false, true]) { + const f = fixture(); f.manager.currentUser.Role = role; + f.nodes[batch ? 'batchAssetExportForm' : 'borrowAssetForm'].dataset.exportForOthers = 'true'; + f.manager.collectBatchAssetExportItems = () => [{ assetId: 1, allocations: [{ projectName: 'Dự án A', quantity: 2 }] }]; + await f.manager[batch ? 'handleBatchAssetExportSubmit' : 'handleBorrowAssetSubmit']({ preventDefault() {} }); + assert.equal(f.requests[0].url, batch ? '/api/assets/export' : '/api/assets/1/export'); + const body = JSON.parse(f.requests[0].options.body); + assert.equal(body.borrowerName, 'Bình'); + assert.deepEqual(batch ? body.items[0].allocations : body.allocations, [{ projectName: 'Dự án A', quantity: 2 }]); + assert.equal(f.documents[0].fileName, 'phieu-xuat.xlsx'); assert.deepEqual(f.refreshes, ['assets']); + assert.equal(f.sandbox.location.hash, '#assets'); assert.equal(f.manager.selectedAssetIds.size, 0); + assert.match(f.messages[0], /Bình/); assert.equal(f.button.disabled, false); + } + } +}); + +test('exporting for others requires manager permission and a recipient for both forms', async () => { + for (const batch of [false, true]) { + for (const role of ['user', 'admin']) { + const f = fixture(); f.manager.currentUser.Role = role; + f.nodes[batch ? 'batchAssetExportForm' : 'borrowAssetForm'].dataset.exportForOthers = 'true'; + f.nodes[batch ? 'batchAssetExportRecipientInput' : 'borrowAssetRecipientInput'].value = ''; + f.manager.collectBatchAssetExportItems = () => [{ assetId: 1, allocations: [{ projectName: 'A', quantity: 1 }] }]; + await f.manager[batch ? 'handleBatchAssetExportSubmit' : 'handleBorrowAssetSubmit']({ preventDefault() {} }); + assert.equal(f.requests.length, 0); assert.equal(f.manager.selectedAssetIds.size, 1); + assert.match(f.messages[0], role === 'user' ? /Asset\/Admin/ : /chọn người nhận/); + } + } +}); + +test('reopening either form as a proposal clears the direct export mode and recipient validation', () => { + for (const prefix of ['borrowAsset', 'batchAssetExport']) { + const f = fixture(); + const form = f.nodes[`${prefix}Form`]; form.querySelector = () => f.button; + for (const suffix of ['RequesterField', 'RecipientField', 'Title', 'Description']) f.nodes[`${prefix}${suffix}`] = {}; + f.nodes[`${prefix}RecipientInput`].id = `${prefix}RecipientInput`; + f.manager.populateUserSelectOptions = id => { f.nodes[id].value = ''; }; + f.manager.configureAssetExportForm(prefix, true); + assert.equal(form.dataset.exportForOthers, 'true'); assert.equal(f.nodes[`${prefix}RequesterField`].hidden, true); + assert.equal(f.nodes[`${prefix}RecipientInput`].required, true); assert.equal(f.button.textContent, 'Xuất và tải Excel'); + f.nodes[`${prefix}RecipientInput`].value = 'Bình'; + f.manager.configureAssetExportForm(prefix, false); + assert.equal(form.dataset.exportForOthers, 'false'); assert.equal(f.nodes[`${prefix}RequesterField`].hidden, false); + assert.equal(f.nodes[`${prefix}RecipientField`].hidden, true); assert.equal(f.nodes[`${prefix}RecipientInput`].value, ''); + assert.equal(f.nodes[`${prefix}RecipientInput`].disabled, true); assert.equal(f.nodes[`${prefix}RecipientInput`].required, false); + assert.equal(f.button.textContent, 'Gửi đơn chờ duyệt'); + } +}); + +test('direct exports block duplicate submissions and preserve selection on server rejection', async () => { + const f = fixture(); let complete; + f.manager.currentUser.Role = 'asset'; f.nodes.borrowAssetForm.dataset.exportForOthers = 'true'; + f.sandbox.fetch = (url, options) => { f.requests.push({ url, options }); return new Promise(resolve => { complete = resolve; }); }; + const first = f.manager.handleBorrowAssetSubmit({ preventDefault() {} }); + await f.manager.handleBorrowAssetSubmit({ preventDefault() {} }); + assert.equal(f.requests.length, 1); assert.equal(f.button.disabled, true); + complete({ ok: false, json: async () => ({ success: false, message: 'Không đủ tồn' }) }); + await first; + assert.equal(f.manager.selectedAssetIds.size, 1); assert.equal(f.documents.length, 0); + assert.equal(f.button.disabled, false); assert.equal(f.messages[0], 'Không đủ tồn'); +}); diff --git a/public/css/asset-actions.css b/public/css/asset-actions.css new file mode 100644 index 0000000..aa6eb2e --- /dev/null +++ b/public/css/asset-actions.css @@ -0,0 +1,364 @@ +/* Asset catalog actions: page utilities and actions on the current selection. */ +.assets-page { + --asset-action-surface: #fff; + --asset-action-text: #334155; + --asset-action-muted: #64748b; + --asset-action-border: #e2e8f0; + --asset-action-tint: #f5f7ff; +} + +.assets-page .asset-page-heading { + position: relative; + z-index: 120; +} + +.asset-page-actions, +.asset-selection-actions { + display: flex; + align-items: center; + gap: 0.5rem; + flex-shrink: 0; +} + +.assets-page .asset-action-button { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 0.5rem; + min-height: 2.5rem; + padding: 0.5625rem 0.875rem; + border: 1px solid var(--asset-action-border); + border-radius: 0.625rem; + background: var(--asset-action-surface); + color: var(--asset-action-text); + font-size: 0.8125rem; + font-weight: 600; + line-height: 1.25; + white-space: nowrap; + cursor: pointer; + touch-action: manipulation; + transition: border-color 0.15s, background-color 0.15s, color 0.15s; +} + +.asset-action-button .material-symbols-outlined, +.asset-menu-item .material-symbols-outlined { + flex-shrink: 0; + font-size: 1.125rem; +} + +.assets-page .asset-action-button:hover:not(:disabled) { + border-color: #b8c4e8; + background: var(--asset-action-tint); + color: #3755c3; +} + +.assets-page .asset-action-primary { + border-color: #3755c3; + background: #3755c3; + color: #fff; + box-shadow: 0 2px 4px rgb(55 85 195 / 0.12); +} + +.assets-page .asset-action-primary:hover:not(:disabled) { + border-color: #2848b7; + background: #2848b7; + color: #fff; +} + +.asset-action-button:focus-visible, +.asset-menu-item:focus-visible, +.asset-selection-clear:focus-visible { + outline: 2px solid #3755c3; + outline-offset: 3px; +} + +.assets-page .asset-action-button:disabled, +.assets-page .asset-menu-item:disabled { + color: #94a3b8; + cursor: not-allowed; +} + +.asset-action-menu { + position: relative; +} + +.asset-action-menu > summary { + list-style: none; +} + +.asset-action-menu > summary::-webkit-details-marker { + display: none; +} + +.asset-action-menu[open] > summary { + border-color: #b8c4e8; + color: #3755c3; + background: var(--asset-action-tint); +} + +.asset-menu-chevron { + transition: transform 0.15s; +} + +.asset-action-menu[open] .asset-menu-chevron { + transform: rotate(180deg); +} + +.asset-menu-panel { + position: absolute; + top: calc(100% + 0.5rem); + right: 0; + z-index: 150; + width: 19rem; + max-width: calc(100vw - 2rem); + max-height: min(28rem, calc(100dvh - 12rem)); + overflow-y: auto; + padding: 0.375rem; + border: 1px solid var(--asset-action-border); + border-radius: 0.875rem; + background: var(--asset-action-surface); + box-shadow: 0 12px 36px rgb(15 23 42 / 0.12), 0 2px 6px rgb(15 23 42 / 0.04); + text-align: left; +} + +.assets-page .asset-menu-label { + margin: 0; + padding: 0.625rem 0.75rem 0.375rem; + color: var(--asset-action-muted); + font-size: 0.6875rem; + font-weight: 700; + letter-spacing: 0.04em; + text-transform: uppercase; +} + +.assets-page .asset-menu-item { + display: flex; + align-items: center; + gap: 0.75rem; + width: 100%; + min-height: 2.75rem; + padding: 0.625rem 0.75rem; + border: 0; + border-radius: 0.5rem; + background: transparent; + color: var(--asset-action-text); + font-size: 0.8125rem; + font-weight: 600; + line-height: 1.4; + text-align: left; + cursor: pointer; +} + +.asset-menu-item small, +.asset-export-action small { + display: block; + margin-top: 0.1875rem; + color: var(--asset-action-muted); + font-size: 0.6875rem; + font-weight: 400; + line-height: 1.35; +} + +.asset-menu-item:hover:not(:disabled) { + background: var(--asset-action-tint); +} + +.asset-menu-item:disabled small { + color: inherit; +} + +.assets-page .asset-menu-danger { + color: #c2413b; +} + +.asset-menu-danger:hover:not(:disabled) { + background: #fff5f4; +} + +.asset-menu-divider { + margin-top: 0.375rem !important; + padding-top: 0.375rem; + border-top: 1px solid var(--asset-action-border); +} + +.asset-selection-toolbar { + position: relative; + z-index: 110; + display: flex; + align-items: center; + justify-content: space-between; + flex-shrink: 0; + gap: 1rem; + margin-bottom: 0.75rem; + padding: 0.75rem 0.875rem; + border: 1px solid var(--asset-action-border); + border-radius: 0.75rem; + background: var(--asset-action-surface); + transition: background-color 0.15s, border-color 0.15s; +} + +.asset-selection-toolbar[data-has-selection="true"] { + border-color: #cdd6f6; + background: var(--asset-action-tint); +} + +.asset-selection-info { + display: grid; + grid-template-columns: auto auto; + align-items: center; + justify-content: start; + gap: 0.3125rem 0.75rem; + min-width: 0; +} + +.asset-selection-status { + display: flex; + align-items: center; + gap: 0.5rem; + color: var(--asset-action-text); + font-size: 0.8125rem; + font-weight: 600; +} + +.asset-selection-count { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 1.625rem; + height: 1.625rem; + padding: 0 0.3125rem; + border-radius: 0.4375rem; + background: #f1f5f9; + color: #64748b; + font-variant-numeric: tabular-nums; +} + +[data-has-selection="true"] .asset-selection-count { + background: #3755c3; + color: #fff; +} + +.asset-selection-hint { + grid-column: 1 / -1; + grid-row: 2; + color: var(--asset-action-muted); + font-size: 0.6875rem; + line-height: 1.4; +} + +.asset-selection-clear { + color: #3755c3; + font-size: 0.75rem; + text-underline-offset: 3px; +} + +.asset-selection-clear:hover { + text-decoration: underline; +} + +.assets-page .asset-export-action { + justify-content: flex-start; + min-height: 3rem; + text-align: left; +} + +.assets-page .asset-action-proposal:not(:disabled) { + border-color: #c2cdf1; + color: #3755c3; +} + +.assets-page .asset-export-action:disabled small { + color: #94a3b8; +} + +@media (max-width: 1200px) { + .asset-selection-toolbar { + flex-wrap: wrap; + } +} + +@media (max-width: 900px) { + .assets-page .asset-page-actions { + flex-wrap: wrap; + width: 100%; + gap: 0.5rem; + } + + .assets-page .asset-page-actions > button, + .assets-page .asset-page-actions > details { + flex: 1 1 auto; + width: auto; + } + + .assets-page .asset-page-actions > details > summary { + width: 100%; + } + + .assets-page .asset-page-actions > .asset-action-primary { + flex: 1 0 100%; + order: -1; + } + + .assets-page .asset-action-button { + min-height: 2.75rem; + } + + .assets-page .asset-page-actions .asset-menu-panel { + right: 0; + } + + .assets-page .asset-filter-bar { + grid-template-columns: minmax(7rem, 0.35fr) minmax(0, 1fr); + } + + .assets-page .asset-filter-bar .compact-filter-search { + grid-column: auto; + grid-row: auto; + } + + .asset-selection-toolbar { + align-items: stretch; + gap: 0.625rem; + padding: 0.75rem; + } + + .asset-selection-info { + padding-right: 3rem; + } + + .asset-selection-actions { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + width: 100%; + } + + .assets-page .asset-export-action { + gap: 0.375rem; + padding: 0.625rem; + font-size: 0.75rem; + white-space: normal; + } + + .asset-selection-menu { + position: absolute; + top: 0.75rem; + right: 0.75rem; + } + + .assets-page .asset-selection-menu > summary { + min-width: 2.75rem; + padding: 0.5rem; + } + + .asset-selection-menu > summary > span:last-child { + display: none; + } +} + +.dark .assets-page { + --asset-action-surface: #172033; + --asset-action-text: #e2e8f0; + --asset-action-muted: #94a3b8; + --asset-action-border: #334155; + --asset-action-tint: #1e293b; +} diff --git a/public/js/app.js b/public/js/app.js index fe9e619..b5f022b 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -2104,6 +2104,7 @@ class AccountManager {
Theo dõi tài sản, kho và trạng thái sử dụng.