Prechádzať zdrojové kódy

dev Template collabora

Marino Faggiana 6 rokov pred
rodič
commit
e49f6e6c84

+ 28 - 1
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -2815,6 +2815,8 @@
         
         if (jsongParsed && jsongParsed.allKeys > 0) {
             
+            NSMutableArray *list = [NSMutableArray new];
+            
             NSDictionary *ocs = [jsongParsed valueForKey:@"ocs"];
             NSDictionary *meta = [ocs valueForKey:@"meta"];
             NSDictionary *data = [ocs valueForKey:@"data"];
@@ -2822,8 +2824,33 @@
             NSInteger statusCode = [[meta valueForKey:@"statuscode"] integerValue];
             
             if (statusCode == kOCUserProfileAPISuccessful) {
+               
+                for (NSDictionary *dicDatas in data) {
+                    
+                    NCRichDocumentTemplate *template = [NCRichDocumentTemplate new];
+                    
+                    if ([dicDatas valueForKey:@"id"] && ![[dicDatas valueForKey:@"id"] isEqual:[NSNull null]])
+                        template.idTemplate = [[dicDatas valueForKey:@"id"] integerValue];
+                    
+                    if ([dicDatas valueForKey:@"delete"] && ![[dicDatas valueForKey:@"delete"] isKindOfClass:[NSNull class]])
+                        template.delete = [dicDatas valueForKey:@"delete"];
+                    
+                    if ([dicDatas valueForKey:@"extension"] && ![[dicDatas valueForKey:@"extension"] isKindOfClass:[NSNull class]])
+                        template.extension = [dicDatas valueForKey:@"extension"];
+                    
+                    if ([dicDatas valueForKey:@"name"] && ![[dicDatas valueForKey:@"name"] isKindOfClass:[NSNull class]])
+                        template.name = [dicDatas valueForKey:@"name"];
+                    
+                    if ([dicDatas valueForKey:@"preview"] && ![[dicDatas valueForKey:@"preview"] isKindOfClass:[NSNull class]])
+                        template.preview = [dicDatas valueForKey:@"preview"];
+                    
+                    if ([dicDatas valueForKey:@"type"] && ![[dicDatas valueForKey:@"type"] isKindOfClass:[NSNull class]])
+                        template.type = [dicDatas valueForKey:@"type"];
+                    
+                    [list addObject:template];
+                }
                 
-                successRequest(response, data, request.redirectedServer);
+                successRequest(response, list, request.redirectedServer);
 
             } else {
                 

+ 146 - 7
iOSClient/Main/CCCreateCloud.swift

@@ -115,16 +115,79 @@ class CreateMenuAdd: NSObject {
     }
 }
 
-
 // MARK: -
 
-class CreateFormUploadRichdocuments: XLFormViewController {
+class CreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate {
     
+    var typeTemplate = ""
+    var serverUrl = ""
+    var fileNameFolder = ""
+    var fileName = ""
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     
     @objc convenience init(typeTemplate : String) {
         self.init()
         
+        self.typeTemplate = typeTemplate
+        serverUrl = appDelegate.activeMain.serverUrl
+        
+        if serverUrl == CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl) {
+            fileNameFolder = "/"
+        } else {
+            fileNameFolder = (serverUrl as NSString).lastPathComponent
+        }
+        
+        self.initializeForm()
+    }
+    
+    func initializeForm() {
+        
+        let form : XLFormDescriptor = XLFormDescriptor(title: NSLocalizedString("_upload_photos_videos_", comment: "")) as XLFormDescriptor
+        form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow
+        
+        var section : XLFormSectionDescriptor
+        var row : XLFormRowDescriptor
+        
+        // Section: Destination Folder
+        
+        section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_save_path_", comment: ""))
+        form.addFormSection(section)
+        
+        row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: fileNameFolder)
+        row.action.formSelector = #selector(changeDestinationFolder(_:))
+        
+        let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:1, color: NCBrandColor.sharedInstance.brandElement) as UIImage
+        row.cellConfig["imageView.image"] = imageFolder
+        
+        row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
+        row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
+        
+        section.addFormRow(row)
+        
+        // Section: File Name
+        
+        section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_filename_", comment: ""))
+        form.addFormSection(section)
+        
+        
+        row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
+        row.value = self.fileName
+        
+        row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
+        
+        row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
+        row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
+        
+        section.addFormRow(row)
+        
+        self.form = form
+    }
+    
+    // MARK: - View Life Cycle
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        
         let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
         
         ocNetworking?.createTemplateRichdocuments(withTemplate: typeTemplate, success: { (listOfTemplate) in
@@ -132,8 +195,86 @@ class CreateFormUploadRichdocuments: XLFormViewController {
         }, failure: { (message, errorCode) in
             //
         })
+        
+        let cancelButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(cancel))
+        let saveButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_save_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(save))
+        
+        self.navigationItem.leftBarButtonItem = cancelButton
+        self.navigationItem.rightBarButtonItem = saveButton
+        
+        self.navigationController?.navigationBar.isTranslucent = false
+        self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.brand
+        self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brandText
+        self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: NCBrandColor.sharedInstance.brandText]
+        
+        self.tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
+        
+        self.reloadForm()
+    }
+    
+    func reloadForm() {
+        
+        self.form.delegate = nil
+        
+        let buttonDestinationFolder : XLFormRowDescriptor  = self.form.formRow(withTag: "ButtonDestinationFolder")!
+        buttonDestinationFolder.title = fileNameFolder
+        
+        self.tableView.reloadData()
+        self.form.delegate = self
+    }
+    
+    // MARK: - Action
+    
+    func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String) {
+        
+        guard let serverUrl = serverUrl else {
+            return
+        }
+        
+        self.serverUrl = serverUrl
+        if serverUrl == CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl) {
+            fileNameFolder = "/"
+        } else {
+            fileNameFolder = (serverUrl as NSString).lastPathComponent
+        }
+        reloadForm()
+    }
+    
+    @objc func changeDestinationFolder(_ sender: XLFormRowDescriptor) {
+        
+        self.deselectFormRow(sender)
+        
+        let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
+        let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
+        let viewController = navigationController.topViewController as! NCSelect
+        
+        viewController.delegate = self
+        viewController.hideButtonCreateFolder = false
+        viewController.includeDirectoryE2EEncryption = false
+        viewController.includeImages = false
+        viewController.layoutViewSelect = k_layout_view_move
+        viewController.selectFile = false
+        viewController.titleButtonDone = NSLocalizedString("_select_", comment: "")
+        viewController.type = ""
+
+        navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+        self.present(navigationController, animated: true, completion: nil)
+    }
+    
+    @objc func save() {
+        
+        self.dismiss(animated: true, completion: {
+            
+            //self.appDelegate.activeMain.uploadFileAsset(self.assets, serverUrl: self.serverUrl, useSubFolder: useSubFolder, session: self.session)
+        })
+    }
+    
+    @objc func cancel() {
+        
+        self.dismiss(animated: true, completion: nil)
     }
 }
+
 // MARK: -
 
 @objc protocol createFormUploadAssetsDelegate {
@@ -141,8 +282,6 @@ class CreateFormUploadRichdocuments: XLFormViewController {
     func dismissFormUploadAssets()
 }
 
-// MARK: -
-
 class CreateFormUploadAssets: XLFormViewController, CCMoveDelegate {
     
     var serverUrl : String = ""
@@ -191,7 +330,7 @@ class CreateFormUploadAssets: XLFormViewController, CCMoveDelegate {
         row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.titleServerUrl)
         row.action.formSelector = #selector(changeDestinationFolder(_:))
 
-        let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:2, color: NCBrandColor.sharedInstance.brandElement) as UIImage
+        let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:1, color: NCBrandColor.sharedInstance.brandElement) as UIImage
         row.cellConfig["imageView.image"] = imageFolder
         
         row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
@@ -533,7 +672,7 @@ class CreateFormUploadFileText: XLFormViewController, CCMoveDelegate {
         row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.titleServerUrl)
         row.action.formSelector = #selector(changeDestinationFolder(_:))
 
-        let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:2, color: NCBrandColor.sharedInstance.brandElement) as UIImage
+        let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:1, color: NCBrandColor.sharedInstance.brandElement) as UIImage
         row.cellConfig["imageView.image"] = imageFolder
         
         row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
@@ -777,7 +916,7 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
         row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.titleServerUrl)
         row.action.formSelector = #selector(changeDestinationFolder(_:))
 
-        let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:2, color: NCBrandColor.sharedInstance.brandElement) as UIImage
+        let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:1, color: NCBrandColor.sharedInstance.brandElement) as UIImage
         row.cellConfig["imageView.image"] = imageFolder
 
         row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue

+ 1 - 0
iOSClient/Nextcloud-Bridging-Header.h

@@ -22,3 +22,4 @@
 #import "OCNotifications.h"
 #import "OCNotificationsAction.h"
 #import "NCNetworkingEndToEnd.h"
+#import "NCRichDocumentTemplate.h"