diff --git a/src/main/java/capstone/lip/landinformationportal/business/bean/ContributeNewRealEstateBean.java b/src/main/java/capstone/lip/landinformationportal/business/bean/ContributeNewRealEstateBean.java index c8852561..727e30f1 100644 --- a/src/main/java/capstone/lip/landinformationportal/business/bean/ContributeNewRealEstateBean.java +++ b/src/main/java/capstone/lip/landinformationportal/business/bean/ContributeNewRealEstateBean.java @@ -579,7 +579,11 @@ public void onChangeLandUnit() { if (landUnit == null) { landUnit = RealEstateTypeConstant.UNIT; } - getHintLandUnit(); + List dataRangeLand = getHintLandDataRange(); + if(dataRangeLand != null && !dataRangeLand.isEmpty()){ + PrimeFaces.current().executeScript("loadLandDataRange('" + dataRangeLand + "')"); + } + PrimeFaces.current().executeScript("loadLandUnit('" + landUnit + "')"); } @@ -593,7 +597,10 @@ public void onChangeHouseUnit() { if (houseUnit == null) { houseUnit = RealEstateTypeConstant.UNIT; } - getHintHouseUnit(); + List dataRangeHouse = getHintHouseDataRange(); + if(dataRangeHouse != null && !dataRangeHouse.isEmpty()){ + PrimeFaces.current().executeScript("loadHouseDataRange('" + dataRangeHouse + "')"); + } PrimeFaces.current().executeScript("loadHouseUnit('" + houseUnit + "')"); } @@ -614,7 +621,9 @@ public void addNewLandFeatureValue() { landsFeatureDataRangeClicked = test.getLandsFeatureDataRange(); if (landsFeatureDataRangeClicked.isEmpty()) { listLandFeatureValue.add(new LandFeatureValue(listLandsFeature.get(i), newLandFeatureValue)); - } else { + } else if(newLandFeatureValue == null || newLandFeatureValue.isEmpty()){ + PrimeFaces.current().executeScript("emptyDataAdd()"); + }else { if (checkDataRange(landsFeatureDataRangeClicked, newLandFeatureValue)) { listLandFeatureValue.add(new LandFeatureValue(listLandsFeature.get(i), newLandFeatureValue)); } else { @@ -660,7 +669,9 @@ public void addNewHousesFeatureValue() { housesFeatureDataRangeClicked = test.getHousesFeatureDataRange(); if (housesFeatureDataRangeClicked.isEmpty()) { listHouseFeatureValue.add(new HouseFeatureValue(listHousesFeature.get(i), newHouseFeatureValue)); - } else { + } else if(newHouseFeatureValue == null || newHouseFeatureValue.isEmpty()){ + PrimeFaces.current().executeScript("emptyDataAdd()"); + }else { if (checkDataRange(housesFeatureDataRangeClicked, newHouseFeatureValue)) { // check data range ok ko ? listHouseFeatureValue.add(new HouseFeatureValue(listHousesFeature.get(i), newHouseFeatureValue)); @@ -677,31 +688,30 @@ public void addNewHousesFeatureValue() { } - public void getHintLandUnit(){ - if (!checkHouseFeatureExisted(houseFeatureIdSelected, listHouseFeatureValue)) { - for (int i = 0; i < listHousesFeature.size(); i++) { + public List getHintLandDataRange(){ + for (int i = 0; i < listLandsFeature.size(); i++) { - if (houseFeatureIdSelected.equals(listHousesFeature.get(i).getHousesFeatureID().toString())) { + if (landFeatureIdSelected.equals(listLandsFeature.get(i).getLandsFeatureID().toString())) { // xử lý data range ở đây - List temp = housesFeatureService.findAll(); - HousesFeature test = new HousesFeature(); + List temp = landFeatureService.findAll(); + LandsFeature test = new LandsFeature(); for (int j = 0; j < temp.size(); j++) { - if (temp.get(j).getHousesFeatureID().toString().equals(houseFeatureIdSelected)) { + if (temp.get(j).getLandsFeatureID().toString().equals(landFeatureIdSelected)) { test = temp.get(j); break; } } - housesFeatureDataRangeClicked = test.getHousesFeatureDataRange(); + landsFeatureDataRangeClicked = test.getLandsFeatureDataRange(); break; } } - - } + return landsFeatureDataRangeClicked; + + } - public void getHintHouseUnit(){ - if (!checkHouseFeatureExisted(houseFeatureIdSelected, listHouseFeatureValue)) { + public List getHintHouseDataRange(){ for (int i = 0; i < listHousesFeature.size(); i++) { if (houseFeatureIdSelected.equals(listHousesFeature.get(i).getHousesFeatureID().toString())) { @@ -718,9 +728,7 @@ public void getHintHouseUnit(){ break; } } - - } - + return housesFeatureDataRangeClicked; } diff --git a/src/main/java/capstone/lip/landinformationportal/business/bean/UpdateContributeRealEstateBean.java b/src/main/java/capstone/lip/landinformationportal/business/bean/UpdateContributeRealEstateBean.java index 470b5faa..b9f0626e 100644 --- a/src/main/java/capstone/lip/landinformationportal/business/bean/UpdateContributeRealEstateBean.java +++ b/src/main/java/capstone/lip/landinformationportal/business/bean/UpdateContributeRealEstateBean.java @@ -593,7 +593,11 @@ public void onChangeLandUnit() { if (landUnit == null) { landUnit = RealEstateTypeConstant.UNIT; } - getHintLandUnit(); + List dataRangeLand = getHintLandDataRange(); + if(dataRangeLand != null && !dataRangeLand.isEmpty()){ + PrimeFaces.current().executeScript("loadLandDataRange('" + dataRangeLand + "')"); + } + PrimeFaces.current().executeScript("loadLandUnit('" + landUnit + "')"); } @@ -607,35 +611,62 @@ public void onChangeHouseUnit() { if (houseUnit == null) { houseUnit = RealEstateTypeConstant.UNIT; } - getHintHouseUnit(); + List dataRangeHouse = getHintHouseDataRange(); + if(dataRangeHouse != null && !dataRangeHouse.isEmpty()){ + PrimeFaces.current().executeScript("loadHouseDataRange('" + dataRangeHouse + "')"); + } PrimeFaces.current().executeScript("loadHouseUnit('" + houseUnit + "')"); } - - - public void getHintLandUnit(){ - if (!checkHouseFeatureExisted(houseFeatureIdSelected, listHouseFeatureValue)) { - for (int i = 0; i < listHousesFeature.size(); i++) { - if (houseFeatureIdSelected.equals(listHousesFeature.get(i).getHousesFeatureID().toString())) { + public void addNewLandFeatureValue() { + if (!checkLandFeatureExisted(landFeatureIdSelected, listLandFeatureValue)) { + for (int i = 0; i < listLandsFeature.size(); i++) { + + if (landFeatureIdSelected.equals(listLandsFeature.get(i).getLandsFeatureID().toString())) { // xử lý data range ở đây - List temp = housesFeatureService.findAll(); - HousesFeature test = new HousesFeature(); + List temp = landFeatureService.findAll(); + LandsFeature test = new LandsFeature(); for (int j = 0; j < temp.size(); j++) { - if (temp.get(j).getHousesFeatureID().toString().equals(houseFeatureIdSelected)) { + if (temp.get(j).getLandsFeatureID().toString().equals(landFeatureIdSelected)) { test = temp.get(j); break; } } - housesFeatureDataRangeClicked = test.getHousesFeatureDataRange(); - break; + landsFeatureDataRangeClicked = test.getLandsFeatureDataRange(); + if (landsFeatureDataRangeClicked.isEmpty()) { + listLandFeatureValue.add(new LandFeatureValue(listLandsFeature.get(i), newLandFeatureValue)); + } else if(newLandFeatureValue == null || newLandFeatureValue.isEmpty()){ + PrimeFaces.current().executeScript("emptyDataAdd()"); + }else { + if (checkDataRange(landsFeatureDataRangeClicked, newLandFeatureValue)) { + listLandFeatureValue.add(new LandFeatureValue(listLandsFeature.get(i), newLandFeatureValue)); + } else { + PrimeFaces.current().executeScript("showLogDataRange()"); + } + } + } } + } else { + // show log + PrimeFaces.current().executeScript("landFeatureExisted()"); } - + } - - public void getHintHouseUnit(){ + + public boolean checkDataRange(List featureDataRangeClicked, String dataCheck) { + boolean test = false; + for (int i = 0; i < featureDataRangeClicked.size(); i++) { + if (featureDataRangeClicked.get(i).trim().equals(dataCheck.trim())) { + test = true; + break; + } + } + return test; + } + + public void addNewHousesFeatureValue() { if (!checkHouseFeatureExisted(houseFeatureIdSelected, listHouseFeatureValue)) { for (int i = 0; i < listHousesFeature.size(); i++) { @@ -650,58 +681,72 @@ public void getHintHouseUnit(){ } } housesFeatureDataRangeClicked = test.getHousesFeatureDataRange(); - break; + if (housesFeatureDataRangeClicked.isEmpty()) { + listHouseFeatureValue.add(new HouseFeatureValue(listHousesFeature.get(i), newHouseFeatureValue)); + } else if(newHouseFeatureValue == null || newHouseFeatureValue.isEmpty()){ + PrimeFaces.current().executeScript("emptyDataAdd()"); + }else { + if (checkDataRange(housesFeatureDataRangeClicked, newHouseFeatureValue)) { + // check data range ok ko ? + listHouseFeatureValue.add(new HouseFeatureValue(listHousesFeature.get(i), newHouseFeatureValue)); + } else { + PrimeFaces.current().executeScript("showLogDataRange()"); + } + } } } + } else { + PrimeFaces.current().executeScript("houseFeatureExisted()"); } - - + } - - public boolean checkDataRange(List featureDataRangeClicked, String dataCheck) { - boolean test = false; - for (int i = 0; i < featureDataRangeClicked.size(); i++) { - if (featureDataRangeClicked.get(i).trim().equals(dataCheck.trim())) { - test = true; - break; - } - } - return test; - } - - - public void addNewLandFeatureValue() { - if (!checkLandFeatureExisted(landFeatureIdSelected, listLandFeatureValue)) { - for (int i = 0; i < listLandsFeature.size(); i++) { + public List getHintLandDataRange(){ + for (int i = 0; i < listLandsFeature.size(); i++) { if (landFeatureIdSelected.equals(listLandsFeature.get(i).getLandsFeatureID().toString())) { - listLandFeatureValue.add(new LandFeatureValue(listLandsFeature.get(i), newLandFeatureValue)); + // xử lý data range ở đây + List temp = landFeatureService.findAll(); + LandsFeature test = new LandsFeature(); + for (int j = 0; j < temp.size(); j++) { + if (temp.get(j).getLandsFeatureID().toString().equals(landFeatureIdSelected)) { + test = temp.get(j); + break; + } + } + landsFeatureDataRangeClicked = test.getLandsFeatureDataRange(); + break; } } - - } else { - // show log - PrimeFaces.current().executeScript("landFeatureExisted()"); - } - + return landsFeatureDataRangeClicked; + + + } - - public void addNewHousesFeatureValue() { - if (!checkHouseFeatureExisted(houseFeatureIdSelected, listHouseFeatureValue)) { + + public List getHintHouseDataRange(){ for (int i = 0; i < listHousesFeature.size(); i++) { if (houseFeatureIdSelected.equals(listHousesFeature.get(i).getHousesFeatureID().toString())) { - listHouseFeatureValue.add(new HouseFeatureValue(listHousesFeature.get(i), newHouseFeatureValue)); + // xử lý data range ở đây + List temp = housesFeatureService.findAll(); + HousesFeature test = new HousesFeature(); + for (int j = 0; j < temp.size(); j++) { + if (temp.get(j).getHousesFeatureID().toString().equals(houseFeatureIdSelected)) { + test = temp.get(j); + break; + } + } + housesFeatureDataRangeClicked = test.getHousesFeatureDataRange(); + break; } } - - } else { - PrimeFaces.current().executeScript("houseFeatureExisted()"); - } - + return housesFeatureDataRangeClicked; + } + + public boolean checkLandFeatureExisted(String landFeatureIdChecking, List listLandFeatureValue) { for (LandFeatureValue i : listLandFeatureValue) { diff --git a/src/main/webapp/resources/css/contributenewrealestate.css b/src/main/webapp/resources/css/contributenewrealestate.css index 0adce8b1..8b91cbc6 100644 --- a/src/main/webapp/resources/css/contributenewrealestate.css +++ b/src/main/webapp/resources/css/contributenewrealestate.css @@ -109,12 +109,7 @@ html { box-sizing: border-box; margin-top: 25px; } -.landbox{ - margin-right: 5px; -} -.housebox{ - margin-left: 5px; -} + .landboxTotal , .houseboxTotal { border-radius: 3px; box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4); diff --git a/src/main/webapp/resources/js/contributenewrealestate.js b/src/main/webapp/resources/js/contributenewrealestate.js index edf7dc53..2ed693a9 100644 --- a/src/main/webapp/resources/js/contributenewrealestate.js +++ b/src/main/webapp/resources/js/contributenewrealestate.js @@ -258,11 +258,22 @@ function validateMap() { } } +function emptyDataAdd() { + alert("Vui lòng nhập giá trị thuộc tính"); +} function loadLandUnit(landUnit) { document.getElementById("landUnit").textContent = landUnit ; } +function loadLandDataRange(dataRange) { + document.getElementById("landDataRange").textContent = "Ví dụ: " + dataRange ; +} + +function loadHouseDataRange(dataRange) { + document.getElementById("houseDataRange").textContent = "Ví dụ: " + dataRange ; +} + function loadHouseUnit(houseUnit) { document.getElementById("houseUnit").textContent = houseUnit; } diff --git a/src/main/webapp/resources/js/updatecontributerealestate.js b/src/main/webapp/resources/js/updatecontributerealestate.js index 8860ee75..3a9d6526 100644 --- a/src/main/webapp/resources/js/updatecontributerealestate.js +++ b/src/main/webapp/resources/js/updatecontributerealestate.js @@ -272,6 +272,14 @@ function showLogDataRange (){ alert("Vui lòng điền giá trị thuộc tính phù hợp theo mẫu"); } +function loadLandDataRange(dataRange) { + document.getElementById("landDataRange").textContent = "Ví dụ: " + dataRange ; +} + +function loadHouseDataRange(dataRange) { + document.getElementById("houseDataRange").textContent = "Ví dụ: " + dataRange ; +} + function showModalMandatory() { tempRealEstateName = $('#msform\\:realEstateName').val(); tempRealEstateValue = $('#msform\\:realEstatePrice').val(); diff --git a/src/main/webapp/user/contributenewrealestate.xhtml b/src/main/webapp/user/contributenewrealestate.xhtml index 73d84e2b..e4152455 100644 --- a/src/main/webapp/user/contributenewrealestate.xhtml +++ b/src/main/webapp/user/contributenewrealestate.xhtml @@ -136,16 +136,17 @@ -
+
+
- + - + - - - + + + + +
Tên phần ĐấtTên phần Đất
Giá trị phần Đất
Giá trị phần Đất @@ -167,10 +168,12 @@
Giá trị thuộc tính (đơn vị) Ví dụ: #{contributeNewRealEstateBean.landsFeatureDataRangeClicked}
@@ -205,19 +208,21 @@ + -
- +
+
+
- + - @@ -235,10 +240,10 @@ - - - + + +
Tên phần NhàTên phần Nhà
Giá trị phần Nhà +
Giá trị phần Nhà (VND)
Giá trị thuộc tính (đơn vị) Ví dụ: #{contributeNewRealEstateBean.housesFeatureDataRangeClicked}
@@ -273,6 +278,7 @@ + @@ -280,13 +286,13 @@
- + - + - - - + + + + +
Tên phần ĐấtTên phần Đất
Giá trị phần Đất
Giá trị phần Đất @@ -308,10 +314,12 @@
Giá trị thuộc tính (đơn vị) Ví dụ: #{contributeNewRealEstateBean.landsFeatureDataRangeClicked}
@@ -350,13 +358,13 @@
- + - @@ -374,10 +382,10 @@ - - - + + + - - - + + + + + - - - + + +
Tên phần NhàTên phần Nhà
Giá trị phần Nhà +
Giá trị phần Nhà (VND)
Giá trị thuộc tính (đơn vị) Ví dụ: #{contributeNewRealEstateBean.housesFeatureDataRangeClicked}
diff --git a/src/main/webapp/user/updatecontributerealestate.xhtml b/src/main/webapp/user/updatecontributerealestate.xhtml index c9845d9f..418823d5 100644 --- a/src/main/webapp/user/updatecontributerealestate.xhtml +++ b/src/main/webapp/user/updatecontributerealestate.xhtml @@ -146,10 +146,12 @@
Giá trị thuộc tính (đơn vị) Ví dụ: #{updateContributeRealEstateBean.landsFeatureDataRangeClicked}
@@ -212,10 +214,10 @@
Giá trị thuộc tính (đơn vị) Ví dụ: #{updateContributeRealEstateBean.housesFeatureDataRangeClicked}