X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/687d5f1cf0e27ab020a2a91d3495ec6edcef0c9f..8e6e6b5651e88009c62f5502b4fabdf2919e0b4f:/src/mewa/presentations.lisp diff --git a/src/mewa/presentations.lisp b/src/mewa/presentations.lisp index 3763c27..53942b1 100644 --- a/src/mewa/presentations.lisp +++ b/src/mewa/presentations.lisp @@ -1,5 +1,8 @@ (in-package :mewa) +(defaction edit-instance ((self mewa)) + (call-presentation (instance self) :type :editor)) + ;;;one-line objects (defcomponent mewa-one-line-presentation (mewa one-line-presentation) () @@ -11,12 +14,34 @@ ;;;objects (defcomponent mewa-object-presentation (mewa ucw:object-presentation) ()) +(defcomponent two-column-presentation (mewa-object-presentation) ()) + +(defmethod present ((pres two-column-presentation)) + + (<:table :class (css-class pres) + (loop for slot on (slots pres) by #'cddr + do + (<:tr :class "presentation-slot-row" + (<:td :class "presentation-slot-label" + (<:as-html (label (first slot)))) + (<:td :class "presentation-slot-value" + (present-slot (first slot) (instance pres))) + (when (second slot) + (<:td :class "presentation-slot-label" + (<:as-html (label (second slot)))) + (<:td :class "presentation-slot-value" + (present-slot (second slot) (instance pres)))))) + (render-options pres (instance pres)))) + + ;;;lists (defcomponent mewa-list-presentation (mewa ucw:list-presentation) - ((instances :accessor instances :initarg :instances :initform nil) + ((ucw::instances :accessor instances :initarg :instances :initform nil) (instance :accessor instance) (select-label :accessor select-label :initform "select" :initarg :select-label) - (selectablep :accessor selectablep :initform t :initarg :selectablep))) + (selectablep :accessor selectablep :initform t :initarg :selectablep) + (ucw::deleteablep :accessor deletablep :initarg :deletablep :initform nil) + (viewablep :accessor viewablep :initarg :viewablep :initform nil))) (defaction select-from-listing ((listing mewa-list-presentation) object index) (answer object)) @@ -39,12 +64,101 @@ (let ((index index)) ( (ucw::number-input self))) + +(def-search-expr ((self ucw::number-equal-to)) + (meta-model:expr-= (ucw::number-input self))) + +(defcomponent mewa-presentation-search (ucw::presentation-search) + ((display-results-p :accessor display-results-p :initarg :display-results-p :initform nil))) + +(defmethod instance ((self mewa:mewa-presentation-search)) + (instance (ucw::search-presentation self))) + +(defmethod search-expr ((self mewa:mewa-presentation-search) instance) + (apply #'meta-model:expr-and instance + (mapcan (lambda (c) (let ((e (search-expr c instance))) + (if (listp e) e (list e)))) + (ucw::criteria self)))) + +(defmethod search-query ((self mewa:mewa-presentation-search)) + (search-expr self (instance self))) + +(defmethod valid-instances ((self mewa:mewa-presentation-search)) + (meta-model:select-instances (instance self) (search-query self))) + +(defmethod get-all-instances ((self mewa-presentation-search)) + (meta-model:select-instances (instance self))) + +(defmethod ok ((self mewa-presentation-search) &optional arg) + (declare (ignore arg)) + (setf (ucw::instances (ucw::list-presentation self)) (valid-instances self)) + (setf (display-results-p self) t)) + + +(defmethod render-on ((res response) (self mewa-presentation-search)) + ;(<:as-html (search-query self)) + (ucw::render-criteria res self) + (