+;;;; * Presentation Searches
+
+
+;;;; ** "search all fields" criteria
+
+(defgeneric search-expr (criteria instance)
+ (:documentation "Return ready to apply criteria.
+ What to do with it is backend dependent."))
+
+(defmacro def-search-expr (((self criteria-type)) (model-expr &body body))
+ `(defmethod search-expr ((,self ,criteria-type) instance)
+ (,model-expr
+ instance
+ (ucw::slot-name (ucw::presentation ,self))
+ ,@body)))
+
+(defmethod search-expr ((self ucw::negated-criteria) instance)
+ (when (ucw::criteria self)
+ (meta-model:expr-not
+ instance
+ (search-expr (ucw::criteria self) instance))))
+
+(def-search-expr ((self ucw::string-starts-with))
+ (meta-model:expr-starts-with (ucw::search-text self)))
+
+(def-search-expr ((self ucw::string-ends-with))
+ (meta-model:expr-ends-with (ucw::search-text self)))
+
+(def-search-expr ((self ucw::string-contains))
+ (meta-model:expr-contains (ucw::search-text self)))
+
+(def-search-expr ((self ucw::number-less-than))
+ (meta-model:expr-< (ucw::number-input self)))
+
+(def-search-expr ((self ucw::number-greater-than))
+ (meta-model:expr-> (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)))