From 833a4d689d3fb1d4b1a274a98ab7af3bc7f9e7a9 Mon Sep 17 00:00:00 2001 From: Peter Howell Date: Tue, 12 Aug 2025 13:39:31 -0700 Subject: [PATCH] change edit screen to grid style --- edit.php | 1 + js/dir_app.js | 841 +++++++++++++++++++++++++++----------------------- layout.php | 1 + peter_db.php | 2 +- style.css | 2 + 5 files changed, 459 insertions(+), 388 deletions(-) diff --git a/edit.php b/edit.php index 5235bcd..47231de 100644 --- a/edit.php +++ b/edit.php @@ -3,4 +3,5 @@ $MY_TITLE = "Edit Sessions"; $MY_CRUMB = "Edit"; $CONTENT = ''; +$XTRAJS = 'js/editor.js'; include 'layout.php'; diff --git a/js/dir_app.js b/js/dir_app.js index 317400a..9892127 100644 --- a/js/dir_app.js +++ b/js/dir_app.js @@ -101,6 +101,8 @@ const TQuestion = Vue.component('field', { "answer": function(val,Oldval) { this.a = val }, "a": function (val, oldVal) { this.$root.events.trigger('changed',[this.qid,this.table, val, this.targetid]) }, }, + mounted() { + }, template: `
+` +}) +// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // +// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // +// +// DISPLAY / EDIT activity or event +// +const ActivityRow = Vue.component('activityrow', { props: { + activity: { type: Object, required: true }, + hosts: { type: Array, default: () => [] }, + everyone: { type: Array, default: () => [] }, + }, + data() { + return { + editing: true, + host_search_str: "", + host_search: [], + this_hosts: [...this.hosts], // local copy for UX + }; + }, + watch: { + host_search_str(val) { + const q = (val || "").toLowerCase(); + this.host_search = q + ? _.first( + this.everyone.filter((x) => x.name.toLowerCase().includes(q)), + 7 + ) + : []; + }, + }, + methods: { + // host ops (call API ONCE per click, not per render) + async removeHost(hostid) { + await new Promise((resolve, reject) => + basic_get(`dir_api.php?a=remove/host/${this.activity.id}/${hostid}`, () => resolve(), reject) + ); + this.this_hosts = this.this_hosts.filter((x) => x.hostid !== hostid); + this.emitPatch({ hostsChanged: true }); + alert_message("Saved"); + }, + async addHost(hostid) { + await new Promise((resolve, reject) => + basic_get(`dir_api.php?a=add/host/${this.activity.id}/${hostid}`, () => resolve(), reject) + ); + const found = _.findWhere(this.everyone, { id: hostid }); + if (found) this.this_hosts.push({ ...found, hostid: hostid }); + this.host_search_str = ""; + this.emitPatch({ hostsChanged: true }); + alert_message("Saved"); + }, + + emitPatch(extra = {}) { + // send minimal changes up; parent recomputes "missing" + this.$emit("patch", { id: this.activity.id, patch: { ...extra } }); + }, + + close() { + this.editing = false; + this.$emit("close"); + }, + }, + mounted() { + this.$nextTick(() => { + const fieldComp = this.$refs.titleField; + console.log(fieldComp) + const inputEl = fieldComp?.$el?.querySelector("input, textarea"); + console.log(inputEl) + if (inputEl) { + inputEl.scrollIntoView({ behavior: "smooth", block: "center" }); + inputEl.focus(); + } + }); + // Listen for Escape while in edit mode + this.keyHandler = (e) => { + if (e.key === "Escape") { + this.$emit("close"); + } + }; + window.addEventListener("keydown", this.keyHandler); + }, + beforeDestroy() { + window.removeEventListener("keydown", this.keyHandler); + }, + template: `
+
+

Edit: {{ activity.title || '(untitled)' }}

+ +
+ + +
+ + + + + + + + + + + +
+ + +
+ +
+
+ {{ h.name }} + +
+
None yet
+
+ +
+ +
+
+ {{ ho.name }} + +
+
+
+
+ + +
+ + +
+ + +
+ + +
+
+` +}) + - // // // // diff --git a/layout.php b/layout.php index 6834c1d..daa31c5 100644 --- a/layout.php +++ b/layout.php @@ -72,5 +72,6 @@ $MOD_DATE = file_exists(__FILE__) ? date("F d Y H:i.", filemtime(__FILE__)) : "(
  + diff --git a/peter_db.php b/peter_db.php index 2f77903..9ffa8c6 100644 --- a/peter_db.php +++ b/peter_db.php @@ -9,7 +9,7 @@ class peter_db { // Constructor to initialize database connection variables public function __construct() { - $this->DBServer = '192.168.1.6'; // Your DB server (example: localhost) + $this->DBServer = '192.168.1.198'; // Your DB server (example: localhost) $this->DBUser = 'phowell'; // Your DB username $this->DBPass = 'rolley34'; // Your DB password $this->DBName = 'db'; // Your DB name diff --git a/style.css b/style.css index d5eef49..88f0297 100644 --- a/style.css +++ b/style.css @@ -1,4 +1,6 @@ .clickme, .clicky {cursor: pointer;} + + .sessiongrid td, .sessiongrid th { vertical-align: top; text-align: left; } .pell{ border:1px solid hsla(0,0%,4%,.1)