Verbeter grafische kwaliteit van kleurplaten (v0.4.67-beta) #5

Open
bes-r wants to merge 208 commits from bes-r/coloring-quality-v0.4.67 into main AGit
5 changed files with 13 additions and 7 deletions
Showing only changes of commit d27419b9f6 - Show all commits

View file

@ -1 +1 @@
0.3.12-beta
0.3.13-beta

View file

@ -66,6 +66,11 @@ function clampWidgetSize(w, h, def){
return { w: fw, h: fh };
}
/* stabiel widget-instantie-id, zelfde patroon als genBoardId() verderop - nodig
zodat een toewijzing van één enkele widget (zie pupil.js/admin.js) die widget
blijft vinden ook als er widgets vóór/na worden toegevoegd of verplaatst */
function genWidgetId(){ return "w" + Date.now().toString(36) + Math.random().toString(36).slice(2,8); }
function makeWidget(def, saved){
const win = document.createElement("div");
win.className = "widget";
@ -222,7 +227,7 @@ function makeWidget(def, saved){
const api = def.mount(body, saved ? saved.state : null) || {};
if(saved && saved.min) setMin(true);
if(saved && saved.max) setMax(true);
const inst = { def, win, api };
const inst = { def, win, api, wid: (saved && saved.wid) || genWidgetId() };
dupBtn.title=T("widgetDuplicate");dupBtn.setAttribute("aria-label",dupBtn.title);previewBtn.title=T("widgetPreview");previewBtn.setAttribute("aria-label",previewBtn.title);
dupBtn.addEventListener("click",()=>makeWidget(def,{x:win.offsetLeft+28,y:win.offsetTop+28,w:win.offsetWidth,h:win.offsetHeight,wz:+win.dataset.wz||1,state:api.getState?structuredClone(api.getState()):null}));
instances.add(inst);
@ -249,6 +254,7 @@ function serializeBoard(){
const max = w.dataset.max === "1";
return {
id: inst.def.id,
wid: inst.wid,
x: max ? +w.dataset.pmx : w.offsetLeft,
y: max ? +w.dataset.pmy : w.offsetTop,
w: min ? (+w.dataset.prevW || inst.def.w) : max ? +w.dataset.pmw : w.offsetWidth,

View file

@ -2,7 +2,7 @@
"use strict";
/* version shown until /api/version resolves (or if the fetch fails, e.g. offline).
Kept in sync by hand with the VERSION file at the repo root on every release. */
const VERSION = "0.3.12-beta";
const VERSION = "0.3.13-beta";
(function(){
const tag = document.getElementById("verTag");
tag.textContent = "v"+VERSION;

View file

@ -34,10 +34,10 @@ function renderPupilWidgets(widgets){
body.className = "widget-body";
card.appendChild(body);
pupilView.appendChild(card);
/* geen stabiel widget-instantie-id in het bord (alleen het widget-type in
w.id) - positie in de lijst is de fijnste identiteit die beschikbaar is,
/* borden die vóór de invoering van stabiele widget-ids zijn opgeslagen
hebben nog geen wid - dan is positie in de lijst de terugval-identiteit,
stabiel zolang de leerkracht de widgets op het bord niet herschikt */
const widgetId = def.id + ":" + idx;
const widgetId = w.wid || (def.id + ":" + idx);
def.mount(body, w.state || null, { readonly:true, onProgress: (p)=>{
api("/my/progress", { method:"POST", body: { widgetId, widgetType: def.id, ...p } }).catch(()=>{});
}});

View file

@ -556,7 +556,7 @@ export default async function api(app) {
if (!a) return { widgets: [], updatedAt: null };
const t = (await pool.query('SELECT data FROM users WHERE id = $1', [a.teacher_id])).rows[0];
const board = t ? findBoardById(t.data, a.board_id) : null;
const widgets = (board?.data?.widgets || []).map((w) => ({ id: w.id, state: w.state }));
const widgets = (board?.data?.widgets || []).map((w) => ({ id: w.id, wid: w.wid, state: w.state }));
return { widgets, updatedAt: a.updated_at };
});