use of com.axelor.common.Inflector in project axelor-open-suite by axelor.
the class ChartRecordViewServiceImpl method getMetaModelActionView.
protected Map<String, Object> getMetaModelActionView(ChartBuilder chartBuilder, Map<String, Object> context) throws AxelorException {
String domain = getDomainFilter(chartBuilder, context);
String simpleName = getModelClass(chartBuilder).getSimpleName();
Inflector instance = Inflector.getInstance();
String dasherizeModel = instance.dasherize(simpleName);
return ActionView.define(I18n.get(instance.humanize(getModelClass(chartBuilder).getSimpleName()))).model(chartBuilder.getModel()).domain(domain).add("grid", dasherizeModel + "-grid").add("form", dasherizeModel + "-form").map();
}
use of com.axelor.common.Inflector in project axelor-open-suite by axelor.
the class ConfiguratorCreatorServiceImpl method completeDefaultGridAndForm.
/**
* Fill {@link MetaJsonField#gridView} and {@link MetaJsonField#formView} in the given meta json
* field. The default views name are using the axelor naming convention, here product
*
* @param metaField a meta field which is a relational field.
* @param newField a meta json field which is a relational field.
*/
protected void completeDefaultGridAndForm(MetaField metaField, MetaJsonField newField) {
String name = metaField.getTypeName();
if (Strings.isNullOrEmpty(name)) {
return;
}
final Inflector inflector = Inflector.getInstance();
String prefix = inflector.dasherize(name);
newField.setGridView(prefix + "-grid");
newField.setFormView(prefix + "-form");
}
use of com.axelor.common.Inflector in project axelor-open-suite by axelor.
the class TraceBackController method showReference.
/**
* Show reference view.
*
* @param request
* @param response
*/
public void showReference(ActionRequest request, ActionResponse response) {
TraceBack traceBack = request.getContext().asType(TraceBack.class);
if (Strings.isNullOrEmpty(traceBack.getRef())) {
return;
}
Class<?> modelClass = JPA.model(traceBack.getRef());
final Inflector inflector = Inflector.getInstance();
String viewName = inflector.dasherize(modelClass.getSimpleName());
LOG.debug("Showing anomaly reference ::: {}", viewName);
ActionViewBuilder actionViewBuilder = ActionView.define(I18n.get("Reference"));
actionViewBuilder.model(traceBack.getRef());
if (traceBack.getRefId() != null) {
actionViewBuilder.context("_showRecord", traceBack.getRefId());
} else {
actionViewBuilder.add("grid", String.format("%s-grid", viewName));
}
actionViewBuilder.add("form", String.format("%s-form", viewName));
response.setView(actionViewBuilder.map());
}
Aggregations