OSDN Git Service

Implementation of the second step of the Design Change function
authoruyaji <yuichiro.uyama@gmail.com>
Mon, 19 Aug 2013 07:30:27 +0000 (16:30 +0900)
committeruyaji <yuichiro.uyama@gmail.com>
Mon, 19 Aug 2013 07:30:27 +0000 (16:30 +0900)
PartsList/PartsList/app/controllers/PartsListController.scala
PartsList/PartsList/app/forms/DesignChangeForm.scala
PartsList/PartsList/app/views/designChangeForm.scala.html
PartsList/PartsList/app/views/main.scala.html
PartsList/PartsList/conf/messages
PartsList/PartsList/conf/messages.en
PartsList/PartsList/conf/messages.ja
PartsList/PartsList/conf/messages.ja-JP

index e8d239c..c55a26a 100644 (file)
@@ -27,11 +27,16 @@ object PartsListController extends Controller{
     
     val designChangeRegistForm = Form(
         mapping(
-            "partsListBean" -> mapping(
+            "partsListBeanBefore" -> mapping(
                 "parent" -> nonEmptyText,
                 "child" -> nonEmptyText,
                 "quantity" -> longNumber
                 )(PartsListBean.apply)(PartsListBean.unapply),
+              "partsListBeanAfter" -> mapping(
+                  "parent" -> nonEmptyText,
+                  "child" -> nonEmptyText,
+                  "quantity" -> longNumber
+                  )(PartsListBean.apply)(PartsListBean.unapply),
             "dcno" -> nonEmptyText
          )(DesignChangeForm.apply)(DesignChangeForm.unapply)
      )
@@ -180,7 +185,7 @@ object PartsListController extends Controller{
        
        def designChangeForm(parentName:String, childName:String) = Action { implicit request =>
                inTransaction {
-                 val designChangeForm = DesignChangeForm(generatePartsListBean(parentName, childName), "")
+                 val designChangeForm = DesignChangeForm(generatePartsListBean(parentName, childName), generatePartsListBean(parentName, childName), "")
                        Ok(views.html.designChangeForm(designChangeRegistForm.fill(designChangeForm)))
                }
        }
@@ -190,13 +195,16 @@ object PartsListController extends Controller{
              formWithErrors => BadRequest(views.html.designChangeForm(formWithErrors)),
              data => {
                  inTransaction {
-                         val parent = getPart(data.partsListBean.parent)
-                         val child = getPart(data.partsListBean.child)
-                         val relation = PartsListDb.partRelations.where(pr => pr.id === (parent.id, child.id)).head
                          val dc = PartsListDb.designChanges.where(dc => dc.dcNo === data.dcno).head
-                         relation.delDcId = dc.id
-                         PartsListDb.partRelations.update(relation)
-                         Home.flashing("success" -> "Relation %s has been changed".format(parent.name + "/" + child.name))
+                         val parent = getPart(data.partsListBeanBefore.parent)
+                         val delRelation = parent.parts.assign(getPart(data.partsListBeanBefore.child))
+                         delRelation.delDcId = dc.id
+                         PartsListDb.partRelations.update(delRelation)
+                         val addRelation = parent.parts.associate(getPart(data.partsListBeanAfter.child))
+                         addRelation.quantity = data.partsListBeanAfter.quantity
+                         addRelation.addDcId = dc.id
+                         PartsListDb.partRelations.update(addRelation)
+                         Home.flashing("success" -> "Relation %s has been changed".format(data.partsListBeanBefore.parent + "/" + data.partsListBeanBefore.child))
                  }
              }
          )
index 95fc175..9f80b78 100644 (file)
@@ -1,6 +1,6 @@
 package forms
 import beans._
 
-case class DesignChangeForm(partsListBean: PartsListBean ,dcno: String) {
+case class DesignChangeForm(partsListBeanBefore: PartsListBean ,partsListBeanAfter: PartsListBean ,dcno: String) {
 
 }
\ No newline at end of file
index 3d50413..94a9f2d 100644 (file)
@@ -4,11 +4,20 @@
 @main("Design Change by Play 2.1") {
        <h1>@Messages("title21")</h1>
        @form(routes.PartsListController.designChange()) {
+               @inputText(designChangeForm("dcno"), '_label -> Messages("list.header10"))
+               <hr />
+               @Messages("form.header10")
                <fieldSet>
-                       @inputText(designChangeForm("partsListBean.parent"), '_label -> Messages("list.header1"), 'readonly -> "readonly")
-                       @inputText(designChangeForm("partsListBean.child"), '_label -> Messages("list.header2"))
-                       @inputText(designChangeForm("partsListBean.quantity"), '_label -> Messages("list.header3"))
-                       @inputText(designChangeForm("dcno"), '_label -> Messages("list.header10"))
+                       @inputText(designChangeForm("partsListBeanBefore.parent"), '_label -> Messages("list.header1"), 'readonly -> "readonly")
+                       @inputText(designChangeForm("partsListBeanBefore.child"), '_label -> Messages("list.header2"), 'readonly -> "readonly")
+                       @inputText(designChangeForm("partsListBeanBefore.quantity"), '_label -> Messages("list.header3"), 'readonly -> "readonly")
+               </fieldSet>
+               <hr />
+               @Messages("form.header11")
+               <fieldSet>
+                       @inputText(designChangeForm("partsListBeanAfter.parent"), '_label -> Messages("list.header1"), 'readonly -> "readonly")
+                       @inputText(designChangeForm("partsListBeanAfter.child"), '_label -> Messages("list.header2"))
+                       @inputText(designChangeForm("partsListBeanAfter.quantity"), '_label -> Messages("list.header3"))
                </fieldSet>
                <div class="action">
                        <input type="submit" class="btn primary" value=@Messages("btn.label4") >
index 87c24b0..a6d7104 100644 (file)
@@ -17,7 +17,7 @@
                        $(document).ready(function() {
                                $('#projectName').autocomplete('@{routes.Autocomplete.projectList()}');
                                $('#child').autocomplete('@{routes.Autocomplete.partList()}');
-                               $('#partsListBean_child').autocomplete('@{routes.Autocomplete.partList()}');
+                               $('#partsListBeanAfter_child').autocomplete('@{routes.Autocomplete.partList()}');
                                $('#users_name').autocomplete('@{routes.Autocomplete.userList()}');
                                $('#dcno').autocomplete('@{routes.Autocomplete.designChangeList()}');
                        });
index 663beb1..3662dbe 100644 (file)
@@ -39,6 +39,8 @@ form.header6=notify message
 form.header7=announcer
 form.header8=answer
 form.header9=answer message
+form.header10=change before
+form.header11=after changing
 form.error1=PartList is the loop.
 title1=Add Part
 title2=Register Relation
index 663beb1..3662dbe 100644 (file)
@@ -39,6 +39,8 @@ form.header6=notify message
 form.header7=announcer
 form.header8=answer
 form.header9=answer message
+form.header10=change before
+form.header11=after changing
 form.error1=PartList is the loop.
 title1=Add Part
 title2=Register Relation
index 94c8476..7fcf43f 100644 (file)
@@ -39,6 +39,8 @@ form.header6=通知メッセージ
 form.header7=発信者
 form.header8=回答者
 form.header9=回答メッセージ
+form.header10=変更前
+form.header11=変更後
 form.error1=部品表がループしています。
 title1=部品登録
 title2=部品表登録
index 0f39d63..7fcf43f 100644 (file)
@@ -8,6 +8,7 @@ list.header6=プロジェクト
 list.header7=担当者
 list.header8=メッセージ
 list.header9=状態
+list.header10=設変番号
 list.link1=部品作成
 list.link2=部品表に戻る
 list.link3=部品表作成
@@ -38,6 +39,8 @@ form.header6=通知メッセージ
 form.header7=発信者
 form.header8=回答者
 form.header9=回答メッセージ
+form.header10=変更前
+form.header11=変更後
 form.error1=部品表がループしています。
 title1=部品登録
 title2=部品表登録
@@ -59,9 +62,11 @@ title17=回答登録
 title18=回答表示
 title19=Open PDM light
 title20=選択してください。
+title21=設計変更
 btn.label1=検索
 btn.label2=通知
 btn.label3=依頼
+btn.label4=変更指示
 issue.message0=通知が、無事発行されました。
 issue.message1=依頼が、無事発行されました。
 issue.message2=回答が、無事発行されました。