OSDN Git Service

Implementation the DesignChangeAppend method.
authoruyaji <yuichiro.uyama@gmail.com>
Thu, 19 Sep 2013 00:22:58 +0000 (09:22 +0900)
committeruyaji <yuichiro.uyama@gmail.com>
Thu, 19 Sep 2013 00:22:58 +0000 (09:22 +0900)
PartsList/PartsList/app/controllers/DesignChangeController.scala
PartsList/PartsList/app/models/services/DesignChangeManager.scala
PartsList/PartsList/app/views/designchangelist.scala.html
PartsList/PartsList/app/views/updateDesignChangeForm.scala.html
PartsList/PartsList/app/views/updatePartForm.scala.html
PartsList/PartsList/app/views/uppartslistshow.scala.html
PartsList/PartsList/conf/messages
PartsList/PartsList/conf/messages.en
PartsList/PartsList/conf/messages.ja
PartsList/PartsList/conf/messages.ja-JP
PartsList/PartsList/conf/routes

index fd45ca7..16d4d00 100644 (file)
@@ -4,11 +4,14 @@ import play.api.i18n._
 import play.api.mvc._
 import play.api.data._
 import play.api.data.Forms._
+import controllers.services._
 import models.services._
 import forms._
+import beans._
 import org.squeryl._
 import org.squeryl.PrimitiveTypeMode._
 import org.squeryl.annotations.Column
+import scala.collection.mutable.ArrayBuffer
 
 object DesignChangeController extends Controller{
    val Home = Redirect(routes.DesignChangeController.list(0,""))
@@ -36,18 +39,23 @@ object DesignChangeController extends Controller{
      )
   }
   
-  def designChangeCoverModify(id: Long) = Action { implicit request =>
+  def designChangeCoverModify(designChangeId: Long, dcSeq: Long, message: String) = Action { implicit request =>
     inTransaction {
-      val designChange = DesignChangeManager().getById(id)
+      var partBuffer = ArrayBuffer[PartsListBean]()
+      val designChange = DesignChangeManager().getById(designChangeId)
       val designChangeForm = DesignChangeForm(designChange.dcNo, designChange.dcDescription)
       val designChangeBuffer = DesignChangeManager().getDesinChangeInformation(designChange)
-      Ok(views.html.updateDesignChangeForm(designChangeRegistForm.fill(designChangeForm), id, designChangeBuffer, designChange.addPartRelation))
+      if(dcSeq != 0) {
+        val delRelation = designChange.delPartRelation.where(pr => pr.dcSeq === dcSeq).head
+        PartRecursion().up(delRelation.child.head, partBuffer, 1)
+      }
+      Ok(views.html.updateDesignChangeForm(designChangeRegistForm.fill(designChangeForm), designChangeId, designChangeBuffer, designChange.addPartRelation, partBuffer, dcSeq, message))
     }
   }
 
   def designChangeCoverModification(id: Long) = Action{ implicit request =>
     designChangeRegistForm.bindFromRequest.fold(
-        formWithErrors => BadRequest(views.html.updateDesignChangeForm(formWithErrors, id, null, null)),
+        formWithErrors => BadRequest(views.html.updateDesignChangeForm(formWithErrors, id, null, null, null, 0, null)),
         designChange => {
           inTransaction {
             DesignChangeManager().update(id, designChange)
@@ -66,10 +74,30 @@ object DesignChangeController extends Controller{
   }
   
   def designChangeCancel(id: Long) = Action { 
-           inTransaction {
-             DesignChangeManager().designChangeCancel(id)
-             Redirect(routes.DesignChangeController.designChangeCoverModify(id))
-           }
+    inTransaction {
+      DesignChangeManager().designChangeCancel(id)
+      Redirect(routes.DesignChangeController.designChangeCoverModify(id, 0, ""))
+     }
+  }
+
+  def designChangeAppend(designChangeId: Long, dcSeq: Long, targetParentName: String) = Action {
+    inTransaction {
+      val designChange = DesignChangeManager().getById(designChangeId)
+      val delRelation =designChange.delPartRelation.where(pr => pr.dcSeq === dcSeq).head 
+      val addRelation =designChange.addPartRelation.where(pr => pr.dcSeq === dcSeq).head 
+      val delPart = delRelation.child.head
+      val addPart = addRelation.child.head
+      val ParentPart = PartManager().getByName(targetParentName)
+      val delPartsListBean = PartsListBean(ParentPart.name, delPart.name, delRelation.quantity)
+      val addPartsListBean = PartsListBean(ParentPart.name, addPart.name, addRelation.quantity)
+      val data = DesignChangeRelationForm(delPartsListBean, addPartsListBean, designChange.dcNo)
+      val message = Check().loopCheckDc(data)
+      if(message == null) {
+        DesignChangeManager().designChange(data)
+        Redirect(routes.DesignChangeController.designChangeCoverModify(designChangeId, dcSeq, ""))
+      } else {
+        Redirect(routes.DesignChangeController.designChangeCoverModify(designChangeId, dcSeq, message))
+      }
+    }
   }
-  
 }
\ No newline at end of file
index 65cb277..829fb71 100644 (file)
@@ -87,6 +87,7 @@ case class DesignChangeManager() {
     }
     for (cancelDelRelation <- cancelDesignChange.delPartRelation) {
       cancelDelRelation.delDcId = 0L
+      cancelDelRelation.dcSeq = 0L
       PartsListDb.partRelations.update(cancelDelRelation) 
     }
   }
index a543d22..09c8604 100644 (file)
@@ -33,8 +33,8 @@
                        <tbody>
                                @for(designChange <- designChanges) {
                                        <tr><td>@designChange.id</td>
-                                       <td><a href="/designChangeCoverModify?id=@designChange.id">@designChange.dcNo</a></td>
-                                       <td><a href="/designChangeCoverModify?id=@designChange.id">@designChange.dcDescription</a></td>
+                                       <td><a href="/designChangeCoverModify?designChangeId=@designChange.id&dcSeq=0&message=">@designChange.dcNo</a></td>
+                                       <td><a href="/designChangeCoverModify?designChangeId=@designChange.id&dcSeq=0&message=">@designChange.dcDescription</a></td>
                                        </tr>
                                }
                        </tbody>
index 968e0cb..9ebf20b 100644 (file)
@@ -1,8 +1,10 @@
-@(designChangeForm: Form[forms.DesignChangeForm], id: Long, delRelations: scala.collection.mutable.ArrayBuffer[beans.DesignChangeListBean], addRelations: org.squeryl.Query[PartRelation])(implicit lang: Lang)
+@(designChangeForm: Form[forms.DesignChangeForm], id: Long, delRelations: scala.collection.mutable.ArrayBuffer[beans.DesignChangeListBean], addRelations: org.squeryl.Query[PartRelation], partBuffer: scala.collection.mutable.ArrayBuffer[beans.PartsListBean], dcSeq: Long, message: String)(implicit lang: Lang)
 @import helper._
 @implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapInput.f) }
 @main("update Design Change by Play 2.1") {
        <h1>@Messages("title22")</h1>
+       @Messages(message)
+       <br>
     <a href="/designchangelist?page=0&key=">@Messages("title21")@Messages("title15")</a>
        &nbsp
        <a href="/designChangeNotifylist?page=0&designChangeId=@id&notifyType=3&state=9">@Messages("notify.type0")@Messages("list.link19")</a>
                        @for(delRelation <- delRelations.sortBy(dcb => dcb.dcSeq)) {
                                <tr>
                                        <td>@delRelation.parentBefore</td>
-                                       <td>@delRelation.childBefore</td>
+                                       <td><a href="/designChangeCoverModify?designChangeId=@id&dcSeq=@delRelation.dcSeq&message=">@delRelation.childBefore</a></td>
                                        <td>@delRelation.parentAfter</td>
                                        <td>@delRelation.childAfter</td>
                                </tr>
                        }
                </tbody>
        </table>
+       @if(partBuffer.size != 0) {
+               <hr />
+               @Messages("title24")
+               <table>
+                       <thead>
+                               <tr>
+                                       <th>@Messages("list.header1")</th><th></th>
+                               </tr>                           
+                       </thead>
+                       <tbody>
+                               @for(target <- partBuffer) {
+                                       <tr>
+                                               <td>@target.child</td>
+                                               <td><a href="/designChangeAppend?designChangeId=@id&dcSeq=@dcSeq&parentName=@target.child">@Messages("list.link18")</a></td>
+                                       </tr>
+                               }
+                       </tbody>
+               </table>
+       }
        <br />
+       <table>
        @form(routes.DesignChangeController.designChangeCancel(id: Long)) {
                <input type="hidden" id="id" value=designChangeForm("id") >
                <input type="submit" class="btn success" value=@Messages("btn.label5") >
        }
+       &nbsp
     @form(routes.NotifyController.createNotify(0, id, 3)) {
        <input type="submit" value=@Messages("btn.label2") class="btn success">
     }
+       &nbsp
     @form(routes.NotifyController.createNotify(0, id, 4)) {
        <input type="submit" value=@Messages("btn.label3") class="btn success">
     }
+    </table>
        <br />
     <a href="/designchangelist?page=0&key=">@Messages("title21")@Messages("title15")</a>
        &nbsp
index 3fbb202..285fa9e 100644 (file)
        &nbsp
        <a href="/notifylist?page=0&partId=@part.id&notifyType=1&state=9">@Messages("notify.type1")@Messages("list.link19")</a>
        
-       @form(routes.PartsMasterController.partModification(id:Long), 'enctype -> "multipart/form-data") {
-               @commonPartForm(partForm)
-       }
        @form(routes.PartsMasterController.partDelete(id), 'class -> "topRight") {
         <input type="submit" value=@Messages("list.link7") class="btn danger">
     }
+       @form(routes.PartsMasterController.partModification(id:Long), 'enctype -> "multipart/form-data") {
+               @commonPartForm(partForm)
+       }
+    <table>
     @form(routes.NotifyController.createNotify(part.id, 0, 0)) {
        <input type="submit" value=@Messages("btn.label2") class="btn success">
     }
+    &nbsp
     @form(routes.NotifyController.createNotify(part.id, 0, 1)) {
        <input type="submit" value=@Messages("btn.label3") class="btn success">
     }
+    </table>
        <table>
        <tr><th>@Messages("form.header2")</th><th></th></tr>
     @for(atach <- part.atachs) {
index 033ccd1..5db489c 100644 (file)
@@ -69,4 +69,8 @@
                <a href="multi_uppartslist?key=&page=0">@Messages("list.link12")</a>
            &nbsp
                <a href="top_uppartslist?key=Part&page=0">@Messages("list.link13")</a>
+               <br />
+           &nbsp
+           <a href="/">@Messages("link.title1")</a>
+
 }
index 50a8995..7adce60 100644 (file)
@@ -71,6 +71,7 @@ title20=Please select.
 title21=Design Change
 title22=Modify Design Change
 title23=Design Change Contents
+title24=Target Unit
 btn.label1=search
 btn.label2=Notification
 btn.label3=Request
index 50a8995..7adce60 100644 (file)
@@ -71,6 +71,7 @@ title20=Please select.
 title21=Design Change
 title22=Modify Design Change
 title23=Design Change Contents
+title24=Target Unit
 btn.label1=search
 btn.label2=Notification
 btn.label3=Request
index 99e87ec..5f82f50 100644 (file)
@@ -71,6 +71,7 @@ title20=選択してください。
 title21=設計変更
 title22=設計変更更新
 title23=変更内容
+title24=変更対象ユニット
 btn.label1=検索
 btn.label2=通知
 btn.label3=依頼
index 99e87ec..5f82f50 100644 (file)
@@ -71,6 +71,7 @@ title20=選択してください。
 title21=設計変更
 title22=設計変更更新
 title23=変更内容
+title24=変更対象ユニット
 btn.label1=検索
 btn.label2=通知
 btn.label3=依頼
index 69fbe97..0791d59 100644 (file)
@@ -24,9 +24,10 @@ GET           /designChangeForm                       controllers.PartsListController.designChangeForm(pare
 POST    /designChange                           controllers.PartsListController.designChange
 GET             /designChangeCoverForm          controllers.DesignChangeController.create
 POST    /designChangeCover                      controllers.DesignChangeController.designChangeCoverRegistration
-GET             /designChangeCoverModify        controllers.DesignChangeController.designChangeCoverModify(id:Long)
+GET             /designChangeCoverModify        controllers.DesignChangeController.designChangeCoverModify(designChangeId:Long, dcSeq:Long, message:String)
 POST    /designChangeCoverModification         controllers.DesignChangeController.designChangeCoverModification(id: Long)
 POST    /designChangeCancel                     controllers.DesignChangeController.designChangeCancel(id:Long)
+GET             /designChangeAppend                     controllers.DesignChangeController.designChangeAppend(designChangeId:Long, dcSeq:Long, parentName:String)
 GET             /projectCreate                          controllers.ProjectController.createProject
 POST    /projectSave                                    controllers.ProjectController.projectRegistration()
 GET             /projectModify                          controllers.ProjectController.updateProject(id:Long)