高级属性编辑

尝试一下在线预览

此示例使用 FeatureForm 微件通过在用户选择视图上的功能时调用 applyEdits 函数来更新现有功能的属性。

不是在各种表单元素中显示所有指定的字段,而是根据它们是否满足指定条件来显示某些字段。它使用在 FieldElementGroupElement 类中找到的 visibilityExpression 属性来执行此操作。此属性采用 Arcade 表达式,如果它解析为 true,则该字段在表单中呈现。

第一个字段元素显示标记为 Issue status的字段。如果值为 CompletedResolution 字段不为空,则将显示标记为 Resolution 的第二个字段。根据 status 字段,状态显示一个或两个分组字段。

                                                                        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

const expressionInfos = [{
  name: "field-resolution",
  expression: "($feature:any.status == 'Completed') && (!(IsEmpty($feature:any.resolution)))"
}, {
  name: "category-AnimalProbType",
  expression: "$feature:any.category == 'Animal'"
}, {
  name: "category-BlightProbType",
  expression: "$feature:any.category == 'Blight'"
}, {
  name: "group-update",
  expression: "($feature:any.status == 'Submitted') || ($feature:any.status == 'Received')"
}];

// This snippet sets individual field elements within the form's template
// Individual field elements to display
const fieldStatus = new FieldElement({
  fieldName: "status",
  editable: false,
  label: "Issue status",
  description: "E.g. submitted, received, in progress, or completed.",
});

const fieldResolution = new FieldElement({
  fieldName: "resolution",
  label: "Resolution",
  editable: false,
  description: "Resolution if status is set to Completed",
  visibilityExpression: "field-resolution",
});

// The following sets field elements and passes it into a group element

const fieldCat = new FieldElement({
  fieldName: "category",
  label: "Category"
});

const fieldAnimal = new FieldElement({
  fieldName: "AnimalProbType",
  label: "Animal problem type",
  visibilityExpression: "category-AnimalProbType",
  description: "E.g. barking dog, bite, etc."
});

const fieldBlight = new FieldElement({
  fieldName: "BlightProbType",
  label: "Blight problem type",
  description: "E.g. graffiti, abandoned vehicle, etc.",
  visibilityExpression: "category-BlightProbType"
});

//Create the group element and pass in the field elements from above
const groupUpdate = new GroupElement({
  label: "Update issue",
  description: "If work has not yet begun on issue, categorize and detail the problem",
  visibilityExpression: "group-update",
  elements: [fieldCat, fieldAnimal, fieldBlight]
});

// Create the feature form and pass in the elements from above into the form template
const form = new FeatureForm({
  container: "form",
  groupDisplay: "sequential",
  formTemplate: {
    title: "Report issues",
    description: "Provide information to the questions below",
    elements: [fieldStatus, fieldResolution, groupUpdate, groupPOC],
    expressionInfos: expressionInfos
  }
});

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.