「動作列」元件是顯示使用者可使用之動作範圍的小器具。動作會顯示為一列按鈕,並顯示在伴隨的清單方塊中。元件組態與使用者螢幕的大小決定顯示為按鈕的動作數。不會顯示為按鈕的任何動作都會顯示在清單方塊中。從·ThingWorx Navigate 9.3.4 開始,清單方塊已取代為省略符號動作。
動作列可包括在「項目清單」與「項目標識」元件內。從 ThingWorx Navigate 9.3.4 開始,「檢視零件清單」、「檢視零件結構」與「檢視文件結構」任務的預覽窗格中也會包含動作列。預覽窗格取代了位於指定任務右上角的選定文件/零件窗格。
下表顯示用來配置此元件的 JSON 內容。
如需有關子內容的詳細資訊,請參閱
子內容與容器金鑰。
內容名稱 | 描述 | 內容類型 | 預設值 | 必要或選用 |
---|
maxItemsToShow | 所顯示的動作按鈕數上限。如果存在的按鈕比所指定值多,將會在清單方塊中填入其他動作。 | | 2 | 必要 |
modelThingName | 包含具有下列簽名之服務的物件名稱: public JSONObject GetActions(@ThingworxServiceParameter(name = "ccoJson", baseType = "JSON") JSONObject ccoJson) 此服務會接受 CCO 格式的輸入,其中包含單一項目。然後,它會傳回包含陣列的 JSONObject,該陣列將可用動作的 ID 對應至其從後端接收的標籤。請參閱下面範例 JSON 組態中的範例。 | | PTC.ActionBar Model.Thing | 必要 |
actions | 需要從後端系統擷取其資料之動作的清單。容器金鑰為 actionConfiguration。請參閱下列子內容: | | N/A | 必要 |
overrideLabel | 此處設定的值會顯示為動作按鈕的標籤,以取代來自後端系統的值。欲本地化,請在值兩邊加上雙括弧。 | | N/A | 選用 |
actionButtonVisibility | 決定動作按鈕在何種條件下顯示,以及處於何種狀態。選項:AlwaysShown、DisableUnavailable、HideUnavailable。對於 AlwaysShown,按鈕始終可見且處於已啟用狀態。對於 DisableUnavailable,按鈕始終可見,但當動作無法用於所提供的選取項時,會禁用。對於 HideUnavailable,只有在動作適用于所提供的選取項時,按鈕才可見。 注意:有其他的組態會影響按鈕是啟用還是禁用狀態。 | | N/A | 必要 |
buttonStyle | 決定按鈕的視覺樣式。選項:primary、secondary、tertiary、danger、transparent。 | | N/A | 必要 |
overrideSetDisabled | 如果設定此欄位,則其值是決定是否應啟用或禁用按鈕的唯一係數。選項:true、false。true 可確保按鈕已禁用,而 false 可確保按鈕已啟用。 | | N/A | 選用 |
fireEventOnFinish | 如果此欄位設定為 true,當服務完成執行時,會觸發 EventTriggered 事件,當關閉快顯時,會觸發 PopupClosed 事件。 | | N/A | 選用 |
inputConstraints | 決定動作的輸入條件約束。選項:InputRequired、SingleInputOnly 與 NoInputRequired。 InputRequired:此動作必須接收輸入才能運作。如果輸入為空且不包含任何項目,則會禁用此動作的按鈕。 SingleInputOnly:此動作必須接收單一輸入才能運作。如果輸入為空或包含多個項目,則會禁用此動作的按鈕。 NoInputRequired:此動作可在沒有任何輸入或有輸入的情況下運作。 | | N/A | 選用 |
iconWhenEnabled | 如果指定此欄位,當啟用動作按鈕時,動作的按鈕會包含圖示,位於標籤左側。 | | | |
entityName | 要作為圖示使用之媒體實體的名稱。 | | | |
iconWhenDisabled | 如果指定此欄位,當禁用動作按鈕時,動作的按鈕會包含圖示,位於標籤左側。 | | | |
entityName | 要作為圖示使用之媒體實體的名稱。 | | | |
activityType | 決定動作是執行服務還是顯示快顯混搭。選項:openUrl (在 ThingWorx Navigate 9.3.4 及更新版本中提供)、popup、service。請參閱下表以取得快顯與服務的必要子内容。 | | N/A | 必要 |
mashupName | 顯示為快顯的混搭名稱。 只有當 activityType 設定為 popup 時,才會使用此內容。 | | N/A | 必要 |
redirectAfterPopupSuccess | 在成功操作後關閉快顯時,會重新導向至另一個混搭。 欲通知動作列快顯所執行的操作已成功完成,請設定名為 PTC.ActionBar.popupCloseParameters 的工作階段參數,以指示成功或失敗。例如,在快顯混搭中,可以有一個運算式,該運算式會在快顯執行的操作完成之後執行,且該運算式會設定工作階段參數。在下列範例中,因為操作成功,JSON 屬性 operationSuccessful 設定為 true: sessionStorage.setItem("PTC.ActionBar.popupCloseParameters", JSON.stringify( { operationSuccessful: true } )); 只有當 activityType 設定為 popup 時,才會使用此內容。 | | N/A | 選用 |
popupWidth | 指定顯示的快顯寬度。 只有當 activityType 設定為 popup 時,才會使用此內容。 | | 1024 | 選用 |
popupHeight | 指定顯示的快顯寬度。 只有當 activityType 設定為 popup 時,才會使用此內容。 | | 640 | 選用 |
thingWithService | 包含要執行之服務的物件名稱。 只有當 activityType 設定為 service 時,才會使用此內容。 | | N/A | 必要 |
serviceName | 要執行的服務名稱。 只有當 activityType 設定為 service 時,才會使用此內容。 | | N/A | 必要 |
parameters | 此選用欄位可用於將硬編碼參數傳遞至服務或快顯混搭。參數在 JSONObject 中定義,且必須使用轉義引號轉換為字串格式的 JSON 物件。參數應以 "{\"myParamName\": \"hardcodedValue\"}" 形式輸入到組態檔案中。請參閱下面的其他資訊。 只有當 activityType 設定為 service 或 popup 時,才會使用此內容。 | | N/A | 選用 |
openUrl | 此內容僅在 ThingWorx Navigate 9.3.4 及更新版本中提供。 |
| 允許在動作按鈕上設定 URL。設定為有效值時,新視窗或標籤會在選取動作按鈕時以設定的 URL 開啟。 只有當 activityType 設定為 openUrl 時,才會使用此內容。 | | N/A | 選用 |
使用 parameters 配置服務動作:
這是名為 MyService 的範例服務的簽名:
@ThingworxServiceDefinition(name = "MyService", category = "MyCategory")
public void MyService(
@ThingworxServiceParameter(name = "exampleInt", baseType = "INTEGER") Integer exampleInt,
@ThingworxServiceParameter(name = "ExampleString", baseType = "STRING") String exampleString,
@ThingworxServiceParameter(name = "ExampleBoolean", baseType = "BOOLEAN") Boolean exampleBoolean)
MyService 之參數值的外觀如下:
{
\"exampleInt\": 123,
\"exampleString\": \"Hello\",
\"exampleBoolean\": true
}
| 如果您定義服務簽名來接收它們,則您的服務會自動取得兩個參數:serviceParam_InputCco 與 serviceParam_ActionId。參數 serviceParam_InputCco 是 JSONObject,是提供給動作列的輸入。參數 serviceParam_ActionId 是字串,其中包含已按一下之動作的 ID。如果您的服務未在其簽名中包含這些參數,則不能使用它們。如果您想要使用它們,請使用下列内容定義您的服務簽名來使用其中之一或兩者: @ThingworxServiceDefinition(name = "MyService", category = "MyCategory") public void MyService( @ThingworxServiceParameter(name = "serviceParam_InputCco", baseType = "JSON") JSONObject serviceParam_InputCco, @ThingworxServiceParameter(name = "serviceParam_ActionId", baseType = "STRING") String serviceParam_ActionId) |
• ThingWorx Navigate 9.3.4 與更新版本
{
"maxItemsToShow": {
"value": 3
},
"modelThingName": {
"entityName": "PTC.ActionBarModel.Thing"
},
"actions": {
"selectedValues": {
"data": [{
"itemListsData": [{
"items": [{
"id": "Approve",
"additionalData": {
"actionConfiguration": {
"actionButtonVisibility": {
"selectedKey": "HideUnavailable"
},
"buttonStyle": {
"selectedKey": "primary"
},
"activityType": {
"selectedKey": "popup"
},
"mashupName": {
"mashupName": "PTC.AccessApp.WindchillServices.RoutingOptionMashup"
},
"fireEventOnFinish": {
"value": false
},
"inputConstraints": {
"selectedKey": "SingleInputOnly"
}
}
},
"ordinal": 10
}, {
"id": "Reassign",
"additionalData": {
"actionConfiguration": {
"overrideLabel": {
"value": "Reassign"
},
"actionButtonVisibility": {
"selectedKey": "AlwaysShown"
},
"buttonStyle": {
"selectedKey": "primary"
},
"activityType": {
"selectedKey": "popup"
},
"mashupName": {
"mashupName": "PTC.AccessApp.WindchillServices.ReassignActionMashup"
},
"fireEventOnFinish": {
"value": false
},
"inputConstraints": {
"selectedKey": "InputRequired"
}
}
},
"ordinal": 20
}, {
"id": "OpenDocument",
"additionalData": {
"actionConfiguration": {
"openUrl": {
"value": "https://www.ptc.com"
},
"overrideLabel": {
"selectedKey": "[[PTC.AccessApp.OpenDocument]]"
},
"buttonStyle": {
"selectedKey": "primary"
},
"activityType": {
"selectedKey": "openUrl"
},
"actionButtonVisibility": {
"selectedKey": "AlwaysShown"
}
},
"ordinal": 30
}
}, {
"id": "ProblemReport",
"additionalData": {
"actionConfiguration": {
"overrideLabel": {
"value": "[[PTC.Nav.CreateProblemReport.AppTitle]]"
},
"popupHeight": {
"value": 640
},
"popupWidth": {
"value": 800
},
"actionButtonVisibility": {
"selectedKey": "AlwaysShown"
},
"buttonStyle": {
"selectedKey": "primary"
},
"mashupName": {
"mashupName": "PTC.Nav.CreateProblemReportAppMashup"
},
"activityType": {
"selectedKey": "popup"
},
"parameters": {
"value": "{\"affectedItemsCCO\":{\"timeStamp\":\"2021-11-24 22:45:54.528\",\"data\":[{\"itemListsData\":[{\"items\":[{\"id\":{\"value\":\"OR:wt.part.WTPart:100447\"}}],\"objectType\":\"PTC.ProdMgmt.Part\"}],\"adapter\":{\"instanceName\":\"windchill\",\"thingName\":\"PTC.WCAdapter\"}}],\"version\":\"1.0.0\",\"statusMessage\":\"OK\",\"status\":\"200\"},\"isPopup\":true}"
}
}
},
"ordinal": 40
}
],
"objectType": "WT.WorkItem.Actions"
}
],
"adapter": {
"instanceName": "windchill",
"thingName": "PTC.WCAdapter"
}
}
]
}
}
}
• ThingWorx Navigate 9.3.0 與更早版本
{
"maxItemsToShow":{
"value":3
},
"modelThingName":{
"entityName":"PTC.ActionBarModel.Thing"
},
"actions":{
"selectedValues":{
"data":[
{
"itemListsData":[
{
"items":[
{
"id":"Approve",
"additionalData":{
"actionConfiguration":{
"overrideLabel":{
"value":""
},
"actionButtonVisibility":{
"selectedKey":"HideUnavailable"
},
"buttonStyle":{
"selectedKey":"primary"
},
"activityType":{
"selectedKey":"popup"
},
"mashupName":{
"mashupName":"PTC.AccessApp.WindchillServices.RoutingOptionMashup"
},
"fireEventOnFinish":{
"value":false
},
"inputConstraints":{
"selectedKey":"SingleInputOnly"
}
}
},
"ordinal":1
},
{
"id":"Reject",
"additionalData":{
"actionConfiguration":{
"overrideLabel":{
"value":""
},
"actionButtonVisibility":{
"selectedKey":"HideUnavailable"
},
"buttonStyle":{
"selectedKey":"primary"
},
"activityType":{
"selectedKey":"popup"
},
"mashupName":{
"mashupName":"PTC.AccessApp.WindchillServices.RoutingOptionMashup"
},
"fireEventOnFinish":{
"value":false
},
"inputConstraints":{
"selectedKey":"SingleInputOnly"
}
}
},
"ordinal":2
},
{
"id":"Analyze",
"additionalData":{
"actionConfiguration":{
"overrideLabel":{
"value":""
},
"actionButtonVisibility":{
"selectedKey":"HideUnavailable"
},
"buttonStyle":{
"selectedKey":"primary"
},
"activityType":{
"selectedKey":"popup"
},
"mashupName":{
"mashupName":"PTC.AccessApp.WindchillServices.RoutingOptionMashup"
},
"fireEventOnFinish":{
"value":false
},
"inputConstraints":{
"selectedKey":"SingleInputOnly"
}
}
},
"ordinal":3
},
{
"id":"Reassign",
"additionalData":{
"actionConfiguration":{
"overrideLabel":{
"value":"Reassign"
},
"actionButtonVisibility":{
"selectedKey":"AlwaysShown"
},
"buttonStyle":{
"selectedKey":"primary"
},
"activityType":{
"selectedKey":"popup"
},
"mashupName":{
"mashupName":"PTC.AccessApp.WindchillServices.ReassignActionMashup"
},
"fireEventOnFinish":{
"value":false
},
"inputConstraints":{
"selectedKey":"InputRequired"
}
}
},
"ordinal":4
}
],
"objectType":"WT.WorkItem.Actions"
}
],
"adapter":{
"instanceName":"windchill",
"thingName":"PTC.WCAdapter"
}
}
]
}
}
}