From ba19c8ae8d80d9a45844f7a70d9931c74fd55696 Mon Sep 17 00:00:00 2001 From: Tina Jin Date: Tue, 23 Apr 2019 10:37:07 -0700 Subject: [PATCH] Added Document Dialog into Edit Feature Attachments sample --- Edit Feature Attachments/MyApp.qml | 41 ++++++++++++++++++++++++++---- Edit Feature Attachments/README.md | 9 ++++--- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/Edit Feature Attachments/MyApp.qml b/Edit Feature Attachments/MyApp.qml index 02e14a8..a90d519 100644 --- a/Edit Feature Attachments/MyApp.qml +++ b/Edit Feature Attachments/MyApp.qml @@ -24,6 +24,7 @@ import QtQuick.Controls.Material 2.1 import ArcGIS.AppFramework 1.0 import ArcGIS.AppFramework.Controls 1.0 import Esri.ArcGISRuntime 100.2 +import ArcGIS.AppFramework.Platform 1.0 import "controls" as Controls @@ -52,11 +53,17 @@ App { Controls.HeaderBar{} } + BusyIndicator{ + id: busy + anchors.centerIn: parent + Material.accent: "#8f499c" + running: false + } + // sample starts here ------------------------------------------------------------------ contentItem: Rectangle{ anchors.top:header.bottom - MapView { id: mapView anchors.fill: parent @@ -100,7 +107,13 @@ App { // signal handler for selecting features onSelectFeaturesStatusChanged: { + if (selectFeaturesStatus === Enums.TaskStatusInProgress) { + // busy.running = true + console.log("######################TaskStatusInProgress") + } + if (selectFeaturesStatus === Enums.TaskStatusCompleted) { + busy.running = false if (!selectFeaturesResult.iterator.hasNext) return; @@ -360,6 +373,9 @@ App { height: width fillMode: Image.PreserveAspectFit source: attachmentUrl + onSourceChanged: { + console.log(source) + } } MouseArea { @@ -381,25 +397,29 @@ App { // file dialog for selecting a file to add as an attachment //! [EditFeatures add attachment from a file dialog] - FileDialog { + DocumentDialog { id: fileDialog function doAddAttachment(){ if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) { selectedFeature.onLoadStatusChanged.disconnect(doAddAttachment); - selectedFeature.attachments.addAttachment(fileDialog.fileUrl, "application/octet-stream", fileInfo.fileName); + selectedFeature.attachments.addAttachment(fileDialog.filePath, "application/octet-stream", fileInfo.fileName); + + } } onAccepted: { // add the attachment to the feature table - fileInfo.url = fileDialog.fileUrl; + fileInfo.url = filePath if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) { - selectedFeature.attachments.addAttachment(fileDialog.fileUrl, "application/octet-stream", fileInfo.fileName); + selectedFeature.attachments.addAttachment(filePath, "application/octet-stream", fileInfo.fileName); } else { selectedFeature.onLoadStatusChanged.connect(doAddAttachment); selectedFeature.load(); } + busy.running = true + console.log(filePath) } } //! [EditFeatures add attachment from a file dialog] @@ -412,6 +432,17 @@ App { FileInfo { id: fileInfo } + + //Show storage permission pop-up on Android + + FileFolder { + id: fileFolder + path: AppFramework.userHomePath + } + + Component.onCompleted: { + fileFolder.makeFolder() + } } } diff --git a/Edit Feature Attachments/README.md b/Edit Feature Attachments/README.md index 047d7b2..eac5136 100644 --- a/Edit Feature Attachments/README.md +++ b/Edit Feature Attachments/README.md @@ -1,10 +1,11 @@ ## Add, delete, and fetch attachments for a specific feature in a feature service. -This sample demonstrates the following: -- Click or tap on a feature to show its callout. The callout specifies the number of attachments for that particular feature. -- Selecting on the info button inside the callout shows the list of those attachments. -- In the list you can add a new attachment by selecting the + button. You can delete an attachment by selecting an attachment and selecting the - button. +Click or tap on a feature to show its callout. The callout specifies the number of attachments for that particular feature. Selecting on the info button inside the callout shows the list of those attachments. In the list, you can add a new attachment by selecting the + button. When clicking on the + button, a native document picker will open, which is invoked by DocumentDialog from AppFramework Platform plugin. You can delete an attachment by selecting an attachment and selecting the - button. This is all controlled through the attachment list model, which is obtained through the feature. The attachment list model works similarly to other QML models and can be directly fed into a list view for easy display and user interaction. + +By default, fetchAttachmentInfos is called automatically for the selected feature, which will request the attachment info JSON from the service. This JSON contains information such as name (the file name) and attachmentUrl (the URL to the file data.) + +To edit the attachments, call addAttachment or deleteAttachment on the AttachmentListModel. By default, edits are automatically applied to the service and applyEdits does not need to be called. [Resource Level](https://geonet.esri.com/groups/appstudio/blog/2016/12/06/how-to-describe-our-resources-in-terms-of-difficulty-complexity-and-time-to-digest): 🍌🍌🍌