X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/31597d71ef8141a1134d75668cfa9ce4f6ecae06..5f0b37e7a9a8e95dd5a846bfa7896af5875b91f7:/src/mewa/presentations.lisp diff --git a/src/mewa/presentations.lisp b/src/mewa/presentations.lisp index 837e9a8..15f0e16 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) () @@ -9,7 +12,20 @@ (or (meta-model:list-keys (instance self)))) ;;;objects -(defcomponent mewa-object-presentation (mewa ucw:object-presentation) ()) +(defcomponent mewa-object-presentation (mewa ucw:object-presentation) + ((ucw::instance :accessor instance :initarg :instance :initform nil))) + +(defmethod present ((pres mewa-object-presentation)) + (<:table :class (css-class pres) + (dolist (slot (slots pres)) + (<:tr :class "presentation-slot-row" + (present-slot-as-row pres slot)))) + (render-options pres (instance pres))) + +(defmethod present-slot-as-row ((pres mewa-object-presentation) (slot ucw::slot-presentation)) + (<:td :class "presentation-slot-label" (<:as-html (label slot))) + (<:td :class "presentation-slot-value" (present-slot slot (instance pres)))) + (defcomponent two-column-presentation (mewa-object-presentation) ()) @@ -36,7 +52,9 @@ ((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)) @@ -59,12 +77,156 @@ (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) + (criteria-input :accessor criteria-input :initform "") + (new-criteria :accessor new-criteria :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 set-search-input-for-criteria ((criteria ucw::criteria) (input t)) + (error "No search-input-for-criteria method for ~A : ~A" criteria input)) + +(defmethod set-search-input-for-criteria ((c ucw::string-criteria) input) + (setf (ucw::search-text c) input)) + +(defmethod set-search-input-for-criteria ((c ucw::negated-criteria) i) + nil) + + +(defmethod mewa-add-criteria ((self component) (criteria ucw::criteria)) + (set-search-input-for-criteria criteria (criteria-input self)) + (ucw::add-criteria self criteria)) + +(defmethod find-default-criteria (c ucw::mewa-string-slot-presentation) + 'ucw::string-contains) + + + +(defmethod render-criteria ((res response) (s mewa-presentation-search)) + (setf (criteria-input s) "") + (<:ul + (dolist (c (criteria s)) + (<:li (render-on res c) + (let ((c c)) + (