-
-
-(defmethod present-slot :around ((slot ajax-foreign-key-slot-presentation) instance)
- (setf (mewa::foreign-instance slot)
- (when (presentation-slot-value slot instance)
- (meta-model:explode-foreign-key instance (slot-name slot))))
- (flet ((render () (when (mewa::foreign-instance slot)(call-next-method))))
- (if (slot-boundp slot 'ucw::place)
- (cond
- ((editablep slot)
- (<ucw:render-component :component (live-search slot))
- (<ucw:submit :action (mewa::search-records slot instance) :value "find" :style "display:inline"))
- ((mewa::linkedp slot)
- (<ucw:a :action (mewa::view-instance slot (foreign-instance slot))
- (render)))
- (t
- (render)))
- ;; presentation is used only for rendering
- (render))))
\ No newline at end of file
+(defaction revert-foreign-slot ((slot ajax-foreign-key-slot-presentation))
+ (setf (lol::value (live-search slot)) nil)
+ (when (original-value slot)
+ (mewa::sync-foreign-instance slot (original-value slot))))
+
+(defmethod present-slot :around ((slot ajax-foreign-key-slot-presentation) instance)
+
+ (let ((foreign-instance
+ (if (lol::value (live-search slot))
+ (lol::value (live-search slot))
+ (setf (original-value slot)
+ (when (presentation-slot-value slot instance)
+ (meta-model:explode-foreign-key instance (slot-name slot)))))))
+
+ (flet ((render-s () (when foreign-instance (call-next-method))))
+ (if (slot-boundp slot 'ucw::place)
+ (cond
+ ((editablep slot)
+ (when foreign-instance
+ (setf (client-value (live-search slot))
+ (with-output-to-string (s)
+ (yaclml:with-yaclml-stream s
+ (present (make-presentation foreign-instance
+ :type :one-line))))))
+
+ (<ucw:render-component :component (live-search slot))
+ #+ (or) (<ucw:submit :action (revert-foreign-slot slot)
+ :value "Undo")
+ (<ucw:submit :action (mewa::search-records slot instance) :value "find" :style "display:inline"))
+ ((mewa::linkedp slot)
+ (<ucw:a :action (mewa::view-instance slot foreign-instance)
+ (render-s)))
+ (t
+ (render-s)))
+ ;; presentation is used only for rendering
+ (render-s)))))
\ No newline at end of file