mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-04 12:17:41 +08:00
PL-9932 Save with values action added to the Filter component
This commit is contained in:
parent
df8fffd819
commit
bf65d96dee
@ -204,7 +204,7 @@ public interface ClientConfig extends Config {
|
|||||||
*/
|
*/
|
||||||
@Property("cuba.gui.genericFilterControlsLayout")
|
@Property("cuba.gui.genericFilterControlsLayout")
|
||||||
@Source(type = SourceType.DATABASE)
|
@Source(type = SourceType.DATABASE)
|
||||||
@Default("[filters_popup] [add_condition] [spacer] [settings | save, save_as, edit, remove, make_default, pin, save_search_folder, save_app_folder] [max_results] [fts_switch]")
|
@Default("[filters_popup] [add_condition] [spacer] [settings | save, save_with_values, save_as, edit, remove, make_default, pin, save_search_folder, save_app_folder] [max_results] [fts_switch]")
|
||||||
String getGenericFilterControlsLayout();
|
String getGenericFilterControlsLayout();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,6 +154,7 @@ public class FilterDelegateImpl implements FilterDelegate {
|
|||||||
protected PopupButton settingsBtn;
|
protected PopupButton settingsBtn;
|
||||||
protected Component applyTo;
|
protected Component applyTo;
|
||||||
protected SaveAction saveAction;
|
protected SaveAction saveAction;
|
||||||
|
protected SaveAction saveWithValuesAction;
|
||||||
protected TextField ftsSearchCriteriaField;
|
protected TextField ftsSearchCriteriaField;
|
||||||
protected CheckBox ftsSwitch;
|
protected CheckBox ftsSwitch;
|
||||||
protected LinkButton addConditionBtn;
|
protected LinkButton addConditionBtn;
|
||||||
@ -628,6 +629,7 @@ public class FilterDelegateImpl implements FilterDelegate {
|
|||||||
boolean saveAsAppFolderActionEnabled = folderActionsEnabled && !isFolder && !hasCode && userCanEditGlobalAppFolder;
|
boolean saveAsAppFolderActionEnabled = folderActionsEnabled && !isFolder && !hasCode && userCanEditGlobalAppFolder;
|
||||||
|
|
||||||
saveAction.setEnabled(saveActionEnabled);
|
saveAction.setEnabled(saveActionEnabled);
|
||||||
|
saveWithValuesAction.setEnabled(filterSavingPossible && !conditions.toConditionsList().isEmpty());
|
||||||
saveAsAction.setEnabled(saveAsActionEnabled);
|
saveAsAction.setEnabled(saveAsActionEnabled);
|
||||||
editAction.setEnabled(editActionEnabled);
|
editAction.setEnabled(editActionEnabled);
|
||||||
removeAction.setEnabled(removeActionEnabled);
|
removeAction.setEnabled(removeActionEnabled);
|
||||||
@ -645,13 +647,15 @@ public class FilterDelegateImpl implements FilterDelegate {
|
|||||||
saveAsSearchFolderAction.setVisible(folderActionsEnabled);
|
saveAsSearchFolderAction.setVisible(folderActionsEnabled);
|
||||||
saveAsAppFolderAction.setVisible(folderActionsEnabled);
|
saveAsAppFolderAction.setVisible(folderActionsEnabled);
|
||||||
saveAction.setVisible(editable);
|
saveAction.setVisible(editable);
|
||||||
|
saveWithValuesAction.setVisible(editable);
|
||||||
saveAsAction.setVisible(editable);
|
saveAsAction.setVisible(editable);
|
||||||
editAction.setVisible(editable);
|
editAction.setVisible(editable);
|
||||||
removeAction.setVisible(editable);
|
removeAction.setVisible(editable);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createFilterActions() {
|
protected void createFilterActions() {
|
||||||
saveAction = new SaveAction();
|
saveAction = new SaveAction("save", false, getMainMessage("filter.save"));
|
||||||
|
saveWithValuesAction = new SaveAction("save_with_values", true, getMainMessage("filter.saveWithValues"));
|
||||||
saveAsAction = new SaveAsAction();
|
saveAsAction = new SaveAsAction();
|
||||||
editAction = new EditAction();
|
editAction = new EditAction();
|
||||||
makeDefaultAction = new MakeDefaultAction();
|
makeDefaultAction = new MakeDefaultAction();
|
||||||
@ -972,6 +976,7 @@ public class FilterDelegateImpl implements FilterDelegate {
|
|||||||
protected void updateFilterModifiedIndicator() {
|
protected void updateFilterModifiedIndicator() {
|
||||||
boolean filterModified = isFilterModified();
|
boolean filterModified = isFilterModified();
|
||||||
saveAction.setEnabled(filterSavingPossible && filterModified);
|
saveAction.setEnabled(filterSavingPossible && filterModified);
|
||||||
|
saveWithValuesAction.setEnabled(filterSavingPossible);
|
||||||
|
|
||||||
String currentCaption = groupBoxLayout.getCaption();
|
String currentCaption = groupBoxLayout.getCaption();
|
||||||
if (StringUtils.isEmpty(currentCaption))
|
if (StringUtils.isEmpty(currentCaption))
|
||||||
@ -2094,8 +2099,13 @@ public class FilterDelegateImpl implements FilterDelegate {
|
|||||||
|
|
||||||
protected class SaveAction extends AbstractAction {
|
protected class SaveAction extends AbstractAction {
|
||||||
|
|
||||||
public SaveAction() {
|
private final boolean saveWithValues;
|
||||||
super("save");
|
protected String caption;
|
||||||
|
|
||||||
|
public SaveAction(String id, boolean saveWithValues, String caption) {
|
||||||
|
super(id);
|
||||||
|
this.saveWithValues = saveWithValues;
|
||||||
|
this.caption = caption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2111,12 +2121,18 @@ public class FilterDelegateImpl implements FilterDelegate {
|
|||||||
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
|
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
|
||||||
String filterName = window.getFilterName();
|
String filterName = window.getFilterName();
|
||||||
filterEntity.setName(filterName);
|
filterEntity.setName(filterName);
|
||||||
|
|
||||||
|
if (saveWithValues) {
|
||||||
|
conditions.toConditionsList().forEach(condition -> {
|
||||||
|
condition.getParam().setDefaultValue(condition.getParam().getValue());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
filterEntity.setXml(filterParser.getXml(conditions, Param.ValueProperty.DEFAULT_VALUE));
|
filterEntity.setXml(filterParser.getXml(conditions, Param.ValueProperty.DEFAULT_VALUE));
|
||||||
saveFilterEntity();
|
saveFilterEntity();
|
||||||
initAdHocFilter();
|
initAdHocFilter();
|
||||||
initFilterSelectComponents();
|
initFilterSelectComponents();
|
||||||
updateWindowCaption();
|
updateWindowCaption();
|
||||||
|
|
||||||
//recreate layout to remove delete conditions buttons
|
//recreate layout to remove delete conditions buttons
|
||||||
initialConditions = conditions.toConditionsList();
|
initialConditions = conditions.toConditionsList();
|
||||||
fillConditionsLayout(ConditionsFocusType.NONE);
|
fillConditionsLayout(ConditionsFocusType.NONE);
|
||||||
@ -2124,16 +2140,23 @@ public class FilterDelegateImpl implements FilterDelegate {
|
|||||||
settingsBtn.requestFocus();
|
settingsBtn.requestFocus();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
if (saveWithValues) {
|
||||||
|
conditions.toConditionsList().forEach(condition -> {
|
||||||
|
condition.getParam().setDefaultValue(condition.getParam().getValue());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
String xml = filterEntity.getFolder() == null ? filterParser.getXml(conditions, Param.ValueProperty.DEFAULT_VALUE)
|
String xml = filterEntity.getFolder() == null ? filterParser.getXml(conditions, Param.ValueProperty.DEFAULT_VALUE)
|
||||||
: filterParser.getXml(conditions, Param.ValueProperty.VALUE);
|
: filterParser.getXml(conditions, Param.ValueProperty.VALUE);
|
||||||
filterEntity.setXml(xml);
|
filterEntity.setXml(xml);
|
||||||
saveFilterEntity();
|
saveFilterEntity();
|
||||||
|
initFilterSelectComponents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCaption() {
|
public String getCaption() {
|
||||||
return getMainMessage("filter.save");
|
return caption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2487,6 +2510,7 @@ public class FilterDelegateImpl implements FilterDelegate {
|
|||||||
|
|
||||||
protected void initFilterActions() {
|
protected void initFilterActions() {
|
||||||
filterActions.put("save", saveAction);
|
filterActions.put("save", saveAction);
|
||||||
|
filterActions.put("save_with_values", saveWithValuesAction);
|
||||||
filterActions.put("save_as", saveAsAction);
|
filterActions.put("save_as", saveAsAction);
|
||||||
filterActions.put("edit", editAction);
|
filterActions.put("edit", editAction);
|
||||||
filterActions.put("remove", removeAction);
|
filterActions.put("remove", removeAction);
|
||||||
@ -2552,6 +2576,7 @@ public class FilterDelegateImpl implements FilterDelegate {
|
|||||||
return controlsLayoutGap;
|
return controlsLayoutGap;
|
||||||
case "pin":
|
case "pin":
|
||||||
case "save":
|
case "save":
|
||||||
|
case "save_with_values":
|
||||||
case "save_as":
|
case "save_as":
|
||||||
case "edit":
|
case "edit":
|
||||||
case "remove":
|
case "remove":
|
||||||
|
@ -350,6 +350,7 @@ filter.removeDialogMessage=Are you sure you want to delete the selected filter?
|
|||||||
filter.search=Search
|
filter.search=Search
|
||||||
filter.addCondition=Add search condition
|
filter.addCondition=Add search condition
|
||||||
filter.save=Save
|
filter.save=Save
|
||||||
|
filter.saveWithValues=Save with values
|
||||||
filter.saveAs=Save as
|
filter.saveAs=Save as
|
||||||
filter.edit=Edit
|
filter.edit=Edit
|
||||||
filter.makeDefault=Make default
|
filter.makeDefault=Make default
|
||||||
|
@ -344,6 +344,7 @@ filter.removeDialogMessage=Удалить выбранный фильтр?
|
|||||||
filter.search=Поиск
|
filter.search=Поиск
|
||||||
filter.addCondition=Добавить условие поиска
|
filter.addCondition=Добавить условие поиска
|
||||||
filter.save=Сохранить
|
filter.save=Сохранить
|
||||||
|
filter.saveWithValues=Сохранить со значениями
|
||||||
filter.saveAs=Сохранить как
|
filter.saveAs=Сохранить как
|
||||||
filter.edit=Редактировать
|
filter.edit=Редактировать
|
||||||
filter.makeDefault=Сделать по умолчанию
|
filter.makeDefault=Сделать по умолчанию
|
||||||
|
Loading…
Reference in New Issue
Block a user