Search in sources :

Example 6 with Record

use of com.extjs.gxt.ui.client.store.Record in project activityinfo by bedatadriven.

the class DbEditor method unsavedChanges.

private BatchCommand unsavedChanges() {
    BatchCommand batch = new BatchCommand();
    for (Record record : treeStore.getModifiedRecords()) {
        EntityDTO entity = (EntityDTO) record.getModel();
        Map<String, Object> changes = new HashMap<>();
        for (String property : record.getChanges().keySet()) {
            changes.put(property, entity.get(property));
        }
        batch.add(new UpdateEntity(entity.getEntityName(), entity.getId(), changes));
    }
    return batch;
}
Also used : Record(com.extjs.gxt.ui.client.store.Record)

Example 7 with Record

use of com.extjs.gxt.ui.client.store.Record in project activityinfo by bedatadriven.

the class DbEditor method onNodeDropped.

private void onNodeDropped(List<TreeStoreModel> data) {
    if (data.isEmpty()) {
        return;
    }
    // update sortOrder and folder membership
    ModelData source = data.get(0).getModel();
    ModelData parent = treeStore.getParent(source);
    LOGGER.info("source = " + source);
    List<ModelData> children = parent == null ? treeStore.getRootItems() : treeStore.getChildren(parent);
    for (int i = 0; i != children.size(); ++i) {
        Record record = treeStore.getRecord(children.get(i));
        record.set("sortOrder", i);
    }
    if (source instanceof ActivityDTO) {
        Record record = treeStore.getRecord(source);
        if (parent instanceof FolderDTO) {
            record.set("folderId", ((FolderDTO) parent).getId());
        } else {
            record.set("folderId", null);
        }
    }
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) Record(com.extjs.gxt.ui.client.store.Record) ActivityDTO(org.activityinfo.legacy.shared.model.ActivityDTO)

Example 8 with Record

use of com.extjs.gxt.ui.client.store.Record in project activityinfo by bedatadriven.

the class OnlyValidFieldBinding method updateModel.

@Override
public void updateModel() {
    if (field.isValid()) {
        if (field instanceof RadioGroup) {
            // special handing for radio group
            RadioGroup radioGroup = (RadioGroup) field;
            // hack : boolean represented with radio buttons : order is important - true is first button, false is second button
            if ("classicView".equals(property)) {
                Field nestedField = radioGroup.getValue();
                int selectedIndex = radioGroup.getAll().indexOf(nestedField);
                boolean val = selectedIndex == 0;
                if (store != null) {
                    Record r = store.getRecord(model);
                    if (r != null) {
                        r.setValid(property, field.isValid());
                        r.set(property, val);
                    }
                } else {
                    model.set(property, val);
                }
                return;
            }
        }
        super.updateModel();
    }
}
Also used : Field(com.extjs.gxt.ui.client.widget.form.Field) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) Record(com.extjs.gxt.ui.client.store.Record)

Aggregations

Record (com.extjs.gxt.ui.client.store.Record)8 ArrayList (java.util.ArrayList)2 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)2 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)2 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 Field (com.extjs.gxt.ui.client.widget.form.Field)1 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 BatchCommand (org.activityinfo.legacy.shared.command.BatchCommand)1 UpdateEntity (org.activityinfo.legacy.shared.command.UpdateEntity)1 UpdateMonthlyReports (org.activityinfo.legacy.shared.command.UpdateMonthlyReports)1 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)1 BatchResult (org.activityinfo.legacy.shared.command.result.BatchResult)1 ActivityDTO (org.activityinfo.legacy.shared.model.ActivityDTO)1 LockedPeriodDTO (org.activityinfo.legacy.shared.model.LockedPeriodDTO)1 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)1 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)1 UserPermissionDTO (org.activityinfo.legacy.shared.model.UserPermissionDTO)1 Promise (org.activityinfo.promise.Promise)1 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)1