OSDN Git Service

Addition the register the parts list link on the matrix parts list.
authoruyaji <yuichiro.uyama@gmail.com>
Mon, 14 Oct 2013 04:22:42 +0000 (13:22 +0900)
committeruyaji <yuichiro.uyama@gmail.com>
Mon, 14 Oct 2013 04:22:42 +0000 (13:22 +0900)
PartsList/PartsList/app/controllers/PartsListController.scala
PartsList/PartsList/app/views/createRelationForm.scala.html
PartsList/PartsList/app/views/matrixpartslistshow.scala.html
PartsList/PartsList/app/views/partslistshow.scala.html
PartsList/PartsList/app/views/partsmastershow.scala.html
PartsList/PartsList/conf/routes

index ea91414..f96a224 100644 (file)
@@ -18,7 +18,7 @@ import scala.collection.mutable._
 object PartsListController extends Controller{
   
    val Home = Redirect(routes.PartsListController.index(0,0,"",""))
-   val Home2 = Redirect(routes.PartsListController.relationRegistration())
+   val Home2 = Redirect(routes.PartsListController.relationRegistration(""))
    val relationForm = Form(
        mapping(
            "parent" -> nonEmptyText,
@@ -89,8 +89,8 @@ object PartsListController extends Controller{
           Ok(views.html.uppartslistshow(partBuffer.drop(page*row).take(row), opt, page, partBuffer.size, key))
        }
        
-       def createRelation(parent:String) = Action {implicit request =>
-         Ok(views.html.createRelationForm(relationForm.fill(new PartsListBean(parent, "", 0, "")),""))
+       def createRelation(parent:String, child:String, project:String) = Action {implicit request =>
+         Ok(views.html.createRelationForm(relationForm.fill(new PartsListBean(parent, child, 0, "")),project, ""))
        }
        
        def updateRelation(parentNo:String, childNo:String, project:String) = Action { implicit request =>
@@ -99,16 +99,20 @@ object PartsListController extends Controller{
          }
        }
        
-       def relationRegistration() = Action { implicit request =>
+       def relationRegistration(project:String) = Action { implicit request =>
          relationForm.bindFromRequest.fold(
-             formWithErrors => BadRequest(views.html.createRelationForm(formWithErrors, "")),
+             formWithErrors => BadRequest(views.html.createRelationForm(formWithErrors, "", "")),
           data => {
                   inTransaction {
                    val message = PartRelationManager().insert(data, null, 0)
                    if( message == null) {
-                         Home.flashing("success" -> "Relation %s has been created".format(data.parent))
+                     if(project=="") {
+                         Home.flashing("success" -> "Relation %s has been created".format(data.parent))
+                     } else {
+                        Redirect(routes.PartsListController.matrixPartList(project))
+                     }
                    } else {
-                Ok(views.html.createRelationForm(relationForm.fill(data), message))
+                Ok(views.html.createRelationForm(relationForm.fill(data), "", message))
                    }
                   }
          }
index 07be10c..ad3fbf0 100644 (file)
@@ -1,10 +1,10 @@
-@(relationForm: Form[beans.PartsListBean], error:String)(implicit lang: Lang)
+@(relationForm: Form[beans.PartsListBean], project:String, error:String)(implicit lang: Lang)
 @import helper._
 @implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapInput.f) } 
 @main("Create relation by Play 2.1") {
        <h1>@Messages("title2")</h1>
        @Messages(error)
-       @form(routes.PartsListController.relationRegistration()) {
+       @form(routes.PartsListController.relationRegistration(project)) {
                <fieldset>
                        @inputText(relationForm("parent"), '_label -> Messages("list.header1"), 'readonly -> "readonly")
                        @inputText(relationForm("child"), '_label -> Messages("list.header2"))
index 8a4ed25..463c73e 100644 (file)
@@ -54,7 +54,7 @@
                                                @if(partsList.showOn == 1) {
                                                        <td><a href="/relationUpdate?parent=@model.name&child=@partsList.part.name&project=@project">@partsList.part.name</a></td>
                                                } else {
-                                                       <td></td>
+                                                       <td><a href="/relationCreate?parent=@model.name&child=@partsList.part.name&project=@project">+</a></td>
                                                }
                                        }
                                        @for(i: Int <- 1 to maxSize - partsListss.apply(model).length) {
index ebc3342..1039d88 100644 (file)
@@ -60,7 +60,7 @@
                        </thead>
                        <tbody>
                                @for(relation <- partsLists) {
-                                       <tr><td><a href="/relationCreate?parent=@relation.parent">@relation.parent</a></td>
+                                       <tr><td><a href="/relationCreate?parent=@relation.parent&child=&project=">@relation.parent</a></td>
                                        <td><a href="/relationUpdate?parent=@relation.parent&child=@relation.child.name&project=">@relation.child.name</a></td>
                                        @inTransaction {
                                                @if(relation.child.atachs){
index 4c2ca08..64f6319 100644 (file)
@@ -39,7 +39,7 @@
                        </thead>
                        <tbody>
                                @for(part <- parts) {
-                                       <tr><td><a href="/relationCreate?parent=@part.name">@part.id</a></td>
+                                       <tr><td><a href="/relationCreate?parent=@part.name&child=&project=">@part.id</a></td>
                                        <td><a href="/partModify?id=@part.id">@part.name</a></td>
                                        @if(part.atachs){
                                                <td><table>
index 65b933b..857fa75 100644 (file)
@@ -17,8 +17,8 @@ GET            /partCreate                                     controllers.PartsMasterController.create
 GET             /partModify                                     controllers.PartsMasterController.update(id:Long)
 POST    /partSave                                               controllers.PartsMasterController.partRegistration()
 POST    /partModification                       controllers.PartsMasterController.partModification(id:Long)
-GET        /relationCreate                              controllers.PartsListController.createRelation(parent:String)
-POST    /relationSave                           controllers.PartsListController.relationRegistration
+GET        /relationCreate                              controllers.PartsListController.createRelation(parent:String, child:String, project:String)
+POST    /relationSave                           controllers.PartsListController.relationRegistration(projeect:String)
 GET        /relationUpdate                              controllers.PartsListController.updateRelation(parent:String, child:String, project:String)
 POST    /relationChange                                 controllers.PartsListController.relationUpdate(childName:String, project:String)
 GET             /designChangeCoverForm          controllers.DesignChangeController.create