X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/b7657b86f85f575d5776dc6b626b1dc258d1fa47..2548f0540da69973512f1827b2bfd2360470bb27:/src/ucw/html-description.lisp diff --git a/src/ucw/html-description.lisp b/src/ucw/html-description.lisp index f05d010..4ec32cc 100644 --- a/src/ucw/html-description.lisp +++ b/src/ucw/html-description.lisp @@ -24,7 +24,8 @@ (define-layered-class html-attribute () ((css-class :accessor attribute-css-class :initform "lol-attribute") - (dom-id :accessor attribute-dom-id :initform nil))) + (dom-id :accessor attribute-dom-id :initform nil) + (display-empty-label :accessor attribute-display-empty-label-p :initarg :display-empty-label-p :initform t))) (define-layered-class standard-attribute :in-layer #.(defining-description 'html-description) @@ -33,25 +34,27 @@ (define-layered-function display-html-attribute-label (object attribute) (:method (object attribute) + (let ((label (attribute-label attribute))) - (<:label + (when (or label (attribute-display-empty-label-p attribute)) + (<:td (<:label :class "lol-attribute-label" (when label (<:as-html (with-output-to-string (*display*) - (display-attribute-label attribute))))))) + (display-attribute-label attribute))))))))) (:method :in-layer #.(defining-description 'inline) (object attribute) (let ((label (attribute-label attribute))) (when label - (<:as-html + (<:as-html (with-output-to-string (*display*) (display-attribute-label attribute))))))) (define-layered-function display-html-attribute-value (object attribute) (:method (object attribute) - (<:span + (<:td :class "lol-attribute-value" (<:as-html (display-attribute-value attribute)))) @@ -63,7 +66,7 @@ (define-layered-function display-html-attribute (object attribute) (:method (object attribute) - (<:div + (<:tr :class (attribute-css-class attribute) (when (attribute-dom-id attribute) :id (attribute-dom-id attribute)) @@ -87,54 +90,102 @@ (display-html-attribute object attribute)) +(defun capture-description (attribute function) + (let ((obj (described-object (attribute-description attribute)))) + (lambda (&rest args) + (dletf (((described-object attribute) obj)) + (apply function args))))) + +(defun make-attribute-value-writer (attribute) + (let ((obj (described-object (attribute-description attribute))) + (value (attribute-value attribute))) + (lambda (val) + (dletf (((described-object attribute) obj)) + (with-active-descriptions (editable) + (unless (and (unbound-slot-value-p value) + (equal "" val)) + (setf (attribute-value attribute) + (parse-attribute-value attribute val)))))))) + + +(defmethod html-attribute-value (attribute) + (let ((val (attribute-value attribute))) + (if (unbound-slot-value-p val) + "" + val))) + +(defmethod display-html-attribute-editor (attribute editor) + (