 
 
 
+
+
+
+
+
+
+
+
+(def thumbinal-edit-form-app-init
+  (merge edit-form-for-id-app-init
+         {:top_description input-app-init
+          :description textarea-app-init
+          :galleria toggle-button-app-init
+          }))
+
+
+(defn thumbnails-edit-form [app owner {:keys [chan-load-for-id
+                                              uri
+                                              chan-load-row
+                                              chan-save
+                                              uri-save
+                                              post-save-fn
+                                              ]
+                                       :as opts}]
+  (reify
+    om/IRender
+    (render [_]
+      (om/build
+       edit-form-for-id app
+       {:opts
+        (merge opts {:fill-app-fn
+                     (fn [{:keys [top_description
+                                  description
+                                  galleria]}]
+                       (om/transact!
+                        app
+                        (fn [app]
+                          (-> app
+                              ;; Заполнение формы
+                              (assoc-in [:top_description :value] top_description)
+                              (assoc-in [:description :value] description)
+                              (assoc-in [:galleria :value] galleria)))))
+                     :app-to-row-fn
+                     (fn []
+                       {:id              (get @app :id)
+                        :top_description (get-in @app [:top_description :value])
+                        :description     (get-in @app [:description :value])
+                        :galleria        (get-in @app [:galleria :value])})
+                     :form-body
+                     (dom/fieldset
+                      nil
+                      (dom/legend nil "Основные данные")
+
+                      (om/build input-form-group (get-in app [:top_description])
+                                {:opts {:label "Наименование"}})
+
+                      (om/build toggle-button-form-group (get-in app [:galleria])
+                                {:opts{:label "Отображать в галерее"}})
+
+                      (om/build textarea-form-group (get-in app [:description])
+                                {:opts {:label "Описание"}})
+                      )
+                     })
+        }))))
+
+
+(def thumbnails-modal-edit-form-app-init
+  (merge modal-edit-form-for-id--YN--app-init thumbinal-edit-form-app-init))
+
+(defn thumbnails-modal-edit-form [app _ opts]
+  (reify
+    om/IRender
+    (render [_]
+      (om/build modal-edit-form-for-id--YN- app
+                {:opts (assoc opts :edit-form-for-id thumbnails-edit-form)}))))
 
 
 (def thumbnails-view-app-init

        (when chan-init-row
          (go
            (while true
              (let [{:keys [id
                            top_description
                            description
                            galleria]} (<! chan-init-row)]
                (om/transact! app
                              (fn [app]
                                (-> app
                                    ;; Заполнение формы
                                    (assoc :id id)
                                    (assoc-in [:top_description :value] top_description)
                                    (assoc-in [:description :value] description)
                                    (assoc-in [:galleria :value] galleria))))
                ))))

        (when chan-save
          (go

                      :className (str "form-control " class+)}))))

(defn input-form-group  [app owner {:keys [label
                                           type
                                           spec-input]
                                    :or {label "Метка"
                                         spec-input {}}}]
  (reify
    om/IRender
    (render [this]
      (dom/div #js {:className (str "form-group " (input-css-string-has? app))}
               (dom/label #js {:className "control-label col-sm-4 col-md-4 col-lg-4"} label)
               (dom/div #js {:className "col-sm-8 col-md-8 col-lg-8"}
                        (om/build input app {:opts spec-input})
                        (om/build helper-p app {})
                        )))))



