Repository :
http://git.fedorahosted.org/cgit/jenkinscat-docs.git
On branch : master
---------------------------------------------------------------
commit 62899ac1becb49f8baec183550b5e590b94c1da0
Author: Pavel Tisnovsky <ptisnovs(a)redhat.com>
Date: Mon Dec 8 12:08:45 2014 +0100
Added 2nd renderer: dialog to add new book/job.
---------------------------------------------------------------
ChangeLog | 7 +-
src/jenkinscat/renderers/add_book_step_2_page.clj | 181 +++++++++++++++++++++
2 files changed, 187 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b067736..fdd1bf4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,13 @@
2014-12-08 Pavel Tisnovsky <ptisnovs(a)redhat.com>
- * src/jenkinscat/renderers/add_book_step_2_error_pages.clj:
+ * src/jenkinscat/renderers/add_book_step_2_page.clj:
Added 2nd renderer: dialog to add new book/job.
+2014-12-08 Pavel Tisnovsky <ptisnovs(a)redhat.com>
+
+ * src/jenkinscat/renderers/add_book_step_2_error_pages.clj:
+ Added 2nd renderer: dialog to add new book/job (error handlers).
+
2014-12-05 Pavel Tisnovsky <ptisnovs(a)redhat.com>
* src/jenkinscat/renderers/add_book_step_1_page.clj:
diff --git a/src/jenkinscat/renderers/add_book_step_2_page.clj
b/src/jenkinscat/renderers/add_book_step_2_page.clj
new file mode 100644
index 0000000..262719f
--- /dev/null
+++ b/src/jenkinscat/renderers/add_book_step_2_page.clj
@@ -0,0 +1,181 @@
+;;;
+;;; Jenkinscat HTTP server that handles all requests send from clients/browsers.
+;;;
+;;; Copyright (c) 2014 Pavel Tisnovsky, Red Hat
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions are met:
+;;; * Redistributions of source code must retain the above copyright
+;;; notice, this list of conditions and the following disclaimer.
+;;; * Redistributions in binary form must reproduce the above copyright
+;;; notice, this list of conditions and the following disclaimer in the
+;;; documentation and/or other materials provided with the distribution.
+;;; * Neither the name of the Red Hat nor the
+;;; names of its contributors may be used to endorse or promote products
+;;; derived from this software without specific prior written permission.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND
+;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+;;; DISCLAIMED. IN NO EVENT SHALL Pavel Tisnovsky BE LIABLE FOR ANY
+;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+;;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+;;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+;;; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;;;
+
+
+
+(ns jenkinscat.renderers.add-book-step-2-page)
+
+(require '[hiccup.core :as hiccup])
+(require '[hiccup.page :as page])
+(require '[hiccup.form :as form])
+
+(require '[jenkinscat.renderers.page-header :as page-header-renderer])
+(require '[jenkinscat.renderers.navigation-bar :as navigation-bar-renderer])
+
+(defn get-item-from-map
+ [the-map key]
+ (if the-map
+ (get the-map key "")
+ ""))
+
+(defn danger-style-for-missing-info
+ [the-map key]
+ (if the-map
+ (if (get the-map key)
+ ""
+ {:class "danger"})
+ ""))
+
+(defn warning-style-for-missing-info
+ [the-map key]
+ (if the-map
+ (if (get the-map key)
+ ""
+ {:class "warning"})
+ ""))
+
+(defn render-add-book-step-2
+ "Render page on which user can change/enter all metainformations about the
book."
+ [repository-type repository-name repository-url book-info devel-version message]
+ (page/xhtml
+ (page-header-renderer/page-header "add book, step 2")
+ [:body
+ (navigation-bar-renderer/navigation-bar "Add book")
+ (form/form-to [:post "/add-book-step-3"]
+ [:div {:class "col-md-10"}
+ [:h2 "Add book, step 2/3"]
+ [:table {:class "table table-condensed table-hover
table-borderer"}
+ [:tr
+ [:td {:colspan "3"} message]
+ ]
+ [:tr (danger-style-for-missing-info book-info :document-title)
+ [:td {:width "30%"} "Book name:"]
+ [:td (form/text-field {:size "40" :class
"-form-control" :style "border-width:1px;border-color:red"}
"document-title" (get-item-from-map book-info :document-title))]
+ [:td "(this field is required)"]
+ ]
+ [:tr [:td " "] [:td " "]
[:td " "]]
+ [:tr (danger-style-for-missing-info book-info :product-name)
+ [:td "Product name:"]
+ [:td (form/text-field {:size "40" :class
"-form-control"} "product-name" (get-item-from-map book-info
:product-name))]
+ [:td "(this field is required)"]
+ ]
+ [:tr (danger-style-for-missing-info book-info :product-number)
+ [:td "Product number"]
+ [:td (form/text-field {:size "20" :class
"-form-control"} "product-number" (get-item-from-map book-info
:product-number))]
+ [:td "(this field is required)"]
+ ]
+ [:tr [:td " "] [:td " "]
[:td " "]]
+ [:tr (warning-style-for-missing-info book-info :component-name)
+ [:td "Bugzilla component name:"]
+ [:td (form/text-field {:size "40" :class
"-form-control"} "component-name" (get-item-from-map book-info
:component-name))]
+ [:td " "]
+ ]
+ [:tr (warning-style-for-missing-info book-info
:component-product)
+ [:td "Bugzilla product name for given component:"]
+ [:td (form/text-field {:size "40" :class
"-form-control"} "component-product" (get-item-from-map book-info
:component-product))]
+ [:td " "]
+ ]
+ [:tr [:td " "] [:td " "]
[:td " "]]
+ [:tr
+ [:td "Repository: (not editable)"]
+ [:td " "]
+ [:td " "]
+ ]
+ [:tr
+ [:td "Repository type:"]
+ [:td (form/text-field {:size "20" :class
"-form-control" :readonly "readonly"} "repository-type"
repository-type)]
+ [:td " "]
+ ]
+ [:tr
+ [:td "Repository name:"]
+ [:td (form/text-field {:size "70" :class
"-form-control" :readonly "readonly"} "repository-name"
repository-name)]
+ [:td " "]
+ ]
+ [:tr
+ [:td "Repository URL"]
+ [:td (form/text-field {:size "100" :class
"-form-control" :readonly "readonly"} "repository-url"
repository-url)]
+ [:td " "]
+ ]
+ [:tr [:td " "] [:td " "]
[:td " "]]
+ [:tr
+ [:td " "]
+ [:td (form/submit-button {:class "btn btn-primary"}
"Continue")]
+ [:td " "]
+ ]
+ ]]
+ )
+ (if devel-version
+ [:div {:class "col-md-10"}
+ "<a
href='/add-book-step-3?repository-url=git://git.app.eng.bos.redhat.co...
info</a>"
+ ]
+ )
+ (if devel-version
+ [:div {:class "col-md-10"}
+ "<a
href='/add-book-step-3?repository-url=git://git.app.eng.bos.redhat.co...
book name"
+ ]
+ )
+ (if devel-version
+ [:div {:class "col-md-10"}
+ "<a
href='/add-book-step-3?repository-url=git://git.app.eng.bos.redhat.co...
product name</a>"
+ ]
+ )
+ (if devel-version
+ [:div {:class "col-md-10"}
+ "<a
href='/add-book-step-3?repository-url=git://git.app.eng.bos.redhat.co...
product version</a>"
+ ]
+ )
+ (if devel-version
+ [:div {:class "col-md-10"}
+ "<a
href='/add-book-step-3?repository-url=git://git.app.eng.bos.redhat.co...
repository type</a>"
+ ]
+ )
+ (if devel-version
+ [:div {:class "col-md-10"}
+ "<a
href='/add-book-step-3?repository-url=git://git.app.eng.bos.redhat.co...
repository name</a>"
+ ]
+ )
+ (if devel-version
+ [:div {:class "col-md-10"}
+ "<a
href='/add-book-step-3?document-title=1.1%20Release%20Notes&product-name=Red%20Hat%20Developer%20Toolset&product-number=1.1&repository-name=doc-Red_Hat_Developer_Toolset-1-Release_Notes.git&repository-type=Gerrit%20(internal%20GIT)&component-product=Red%20Hat%20Developer%20Toolset&component-name=doc-Release_Notes&'>Missing
repository URL</a>"
+ ]
+ )
+]))
+
+(defn render-add-book-step-2-already-have-bookinfo
+ "Render page with a message that book info can be read."
+ [repository-type repository-name repository-url book-info devel-version]
+ (render-add-book-step-2 repository-type repository-name repository-url book-info
devel-version
+ "The following metainformations have been read from the book repository.
Please check them and update properly."))
+
+(defn render-add-book-step-2-enter-some-bookinfo
+ "Render page with a message that book info can't be read and it needs to be
filled."
+ [repository-type repository-name repository-url book-info devel-version]
+ (render-add-book-step-2 repository-type repository-name repository-url book-info
devel-version
+ "Not all metainformations could be read from the book repository, please
fill in the following entries"))
+