Skip to content

Commit

Permalink
Fix issue 199
Browse files Browse the repository at this point in the history
  • Loading branch information
clun committed Mar 13, 2017
1 parent 3e2ed50 commit 6ca6313
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,30 @@ public static void updateProperty(FF4j ff4j, HttpServletRequest req) {
String description = req.getParameter("desc");
String value = req.getParameter("pValue");
String uid = req.getParameter("uid");
String featureId = req.getParameter(WebConstants.FEATURE_UID);

Property<?> ap;
// To update the core the uid is the name (rename, edit)
if (uid == null) {
uid = name;
}
if (ff4j.getPropertiesStore().existProperty(uid)) {

// Update Feature property
if (Util.hasLength(featureId)) {

Feature current = ff4j.getFeatureStore().read(featureId);
ap = current.getProperty(uid);
ap.setDescription(description);
if (ap.getType().equalsIgnoreCase(type)) {
ap.setValueFromString(value);
} else {
ap = PropertyFactory.createProperty(name, type, value);
LOGGER.warn("By changing property type you loose the fixedValues, cannot evaluate ? at runtime");
}
ff4j.getFeatureStore().update(current);

} else if (ff4j.getPropertiesStore().existProperty(uid)) {

// Do not change name, just and update
if (uid.equalsIgnoreCase(name)) {
ap = ff4j.getPropertiesStore().readProperty(uid);
Expand Down
1 change: 0 additions & 1 deletion ff4j-web/src/main/resources/static/js/ff4j.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ function confirmBeforeDeleteFeature(feature) {
});*/
}


// Display Custom Properties for current feature in the table
function showCustomProperties(uid) {
show('detailCustomP-' + uid);
Expand Down
3 changes: 1 addition & 2 deletions ff4j-web/src/main/resources/views/view-modal-features.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ <h4 id="myModalLabel">
</tbody>
</table>
</div>
</div><!-- Control group -->

</div><!-- Control group -->

<!-- Properties -->
<div class="control-group" style="margin-left:0px;float:left;margin-left:-45px">
Expand Down
6 changes: 4 additions & 2 deletions ff4j-web/src/main/resources/views/view-modal-properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ <h4 id="modalDeletePropertyLabel"><i class="icon-trasht"></i>&nbsp;
<!-- *********************** -->
<!-- FORM UPDATE PROPERTY -->
<!-- *********************** -->

<div th:fragment="modal-updateProperty">

<form id="updatePropertyForm"
Expand Down Expand Up @@ -299,12 +300,13 @@ <h4 id="myModalLabel">
ff4j_updateModalDeleteProperty($(this).data('id'));
});


$(document).on("click", ".open-EditFeaturePropertyDialog", function () {
var featureId = $(this).data('featureid');
var propertyName = $(this).data('propertyname');
var modalEditProperty = $("#modalEditProperty");
$("#updatePropertyFeatureControlGroup").show();
// Edition of fixedValue for properties related on feature is disabled : Should recreate all create, delete, update, generation HTML
// <--
$("#updatePropertyFixedValueControlGroup").hide();
modalEditProperty.find("#name").val(propertyName);
modalEditProperty.find("#featureid").val(featureId);
Expand Down Expand Up @@ -457,7 +459,7 @@ <h4 id="myModalLabel">
</div>

<!-- ******************** -->
<!-- MODAL COPY FEATURE -->
<!-- MODAL COPY PROPERTY -->
<!-- ******************** -->
<div th:fragment="modal-copy">

Expand Down

0 comments on commit 6ca6313

Please sign in to comment.