Changeset 3708

Show
Ignore:
Timestamp:
07/31/08 11:36:07 (4 months ago)
Author:
ksprotte
Message:

poi image shifting works again

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/projects/bos/m2/poi.lisp

    r3706 r3708  
    149149;;; (nth (1+ index) (poi-sat-images poi)). 
    150150(deftransaction poi-sat-images-exchange-neighbours (poi index)   
    151   (check-type index (integer 0 4)) 
     151  (check-type index (mod 6)) 
    152152  (multiple-value-bind (images positions) 
    153153      (poi-images poi) 
    154154    (declare (ignore images)) 
    155155    (let ((media-index-a (nth index positions)) 
    156           (media-index-b (nth (1+ index) positions))) 
     156          (media-index-b (nth (mod (1+ index) 6) positions))) 
    157157      (rotatef (nth media-index-a (poi-media poi)) 
    158158               (nth media-index-b (poi-media poi)))))) 
  • trunk/projects/bos/web/poi-handlers.lisp

    r3707 r3708  
    5353(defmethod handle-object-form ((handler edit-poi-handler) 
    5454                               action (poi poi)) 
    55   (with-query-params (language shift shift-by
     55  (with-query-params (language shift shift-id
    5656    (unless language (setq language (request-language))) 
    5757    (when shift 
    58       ;; change image order 
    59       (setq shift (find-store-object (parse-integer shift))) 
    60       (setq shift-by (parse-integer shift-by)) 
    61       (let* ((new-images (poi-sat-images poi)) 
    62              (old-position (position shift new-images)) 
    63              (tmp (nth old-position new-images))) 
    64         (assert (and (< -1 old-position (length new-images)) 
    65                      (< -1 (+ shift-by old-position) (length new-images)))) 
    66         (setf (nth old-position new-images) (nth (+ shift-by old-position) new-images)) 
    67         (setf (nth (+ shift-by old-position) new-images) tmp) 
    68         (with-transaction ("setf poi-sat-images") 
    69           (setf (poi-sat-images poi) new-images)))) 
     58      (let ((shift (parse-integer shift)) 
     59            (shift-id (parse-integer shift-id))) 
     60        ;; only if this exchange has not already happened 
     61        (when (= shift-id (store-object-id (nth shift (poi-sat-images poi)))) 
     62          (poi-sat-images-exchange-neighbours poi shift)))) 
    7063    (with-bos-cms-page (:title "Edit POI") 
    7164      (content-language-chooser) 
     
    111104               (:tr 
    112105                (loop for image in (poi-sat-images poi) 
    113                    for index from 1 by 1 
     106                   for index upfrom 0 
    114107                   do (html (:td ((:a :href (format nil "/edit-poi-image/~a?poi=~A" (store-object-id image) (store-object-id poi))) 
    115108                                  ((:img :border "0" :src (format nil "/image/~a/thumbnail,,55,55" (store-object-id image))))) 
    116109                                 :br 
    117                                  (if (eql index 1
     110                                 (if (zerop index
    118111                                     (html ((:img :src "/images/trans.gif" :width "16"))) 
    119                                      (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=-1
    120                                                               (store-object-id poi) 
    121                                                               (store-object-id image))) 
     112                                     (html ((:a :href (format nil "/edit-poi/~A?shift=~D&shift-id=~D
     113                                                              (store-object-id poi) (1- index) 
     114                                                              (store-object-id (nth (1- index) (poi-sat-images poi))))) 
    122115                                            ((:img :border "0" :src "/images/pfeil-l.gif"))))) 
    123116                                 ((:img :src "/images/trans.gif" :width "23")) 
    124117                                 (unless (eql index (length (poi-sat-images poi))) 
    125                                    (html ((:a :href (format nil "/edit-poi/~A?shift=~A&shift-by=1
    126                                                             (store-object-id poi) 
     118                                   (html ((:a :href (format nil "/edit-poi/~A?shift=~D&shift-id=~D
     119                                                            (store-object-id poi) index 
    127120                                                            (store-object-id image))) 
    128121                                          ((:img :border "0" :src "/images/pfeil-r.gif"))))))))))