Skip to content

Commit

Permalink
ACL - Fix sheet bugs... 404, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
auniverseaway committed Jan 14, 2025
1 parent b439523 commit 83d5f3e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions blocks/edit/da-title/da-title.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ h1 {
position: absolute;
width: 18px;
height: 18px;
top: 50%;
top: 18px;
left: -36px;
background: url(/blocks/edit/img/Smock_LockClosed_18_N.svg) center center / 18px no-repeat;
transform: translateY(-50%);
}

.da-title-name-label {
Expand Down
12 changes: 7 additions & 5 deletions blocks/sheet/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '../da-sheet-tabs.js';
const { loadStyle } = await import(`${getNx()}/scripts/nexter.js`);
const loadScript = (await import(`${getNx()}/utils/script.js`)).default;

const SHEET_TEMPLATE = { sheetName: 'data' };
const SHEET_TEMPLATE = { minDimensions: [20, 20], sheetName: 'data' };

let permissions;
let canWrite;
Expand Down Expand Up @@ -39,7 +39,7 @@ function finishSetup(el, data) {

function getDefaultSheet() {
return [
{ ...SHEET_TEMPLATE },
{ ...SHEET_TEMPLATE, minDimensions: [20, 20] },
];
}

Expand Down Expand Up @@ -71,7 +71,8 @@ const getColWidths = (colWidths, headers) => {

function getSheet(json, sheetName) {
const data = getSheetData(json.data);
const templ = canWrite ? { ...SHEET_TEMPLATE, minDimensions: [20, 20] } : SHEET_TEMPLATE;
const templ = { ...SHEET_TEMPLATE };
if (!canWrite) delete templ.minDimensions;

return {
...templ,
Expand All @@ -87,15 +88,16 @@ export function getPermissions() {

export async function getData(url) {
const resp = await daFetch(url);
if (!resp.ok) return getDefaultSheet();

// Set permissions
// Set permissions even if the file is a 404
const daTitle = document.querySelector('da-title');
if (daTitle) daTitle.permissions = resp.permissions;

permissions = resp.permissions;
canWrite = resp.permissions.some((permission) => permission === 'write');

if (!resp.ok) return getDefaultSheet();

const sheets = [];

// Get base data
Expand Down
1 change: 0 additions & 1 deletion blocks/sheet/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function debounce(func, wait) {
}

export const saveSheets = async (sheets) => {
const daTitle = document.querySelector('da-title');
document.querySelector('da-sheet-panes').data = convertSheets(sheets);

const { hash } = window.location;
Expand Down

0 comments on commit 83d5f3e

Please sign in to comment.