diff --git a/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/BBConsentOrganisationViewController.swift b/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/BBConsentOrganisationViewController.swift index c51595b..edee7f7 100644 --- a/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/BBConsentOrganisationViewController.swift +++ b/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/BBConsentOrganisationViewController.swift @@ -36,7 +36,6 @@ class BBConsentOrganisationViewController: BBConsentBaseViewController { setupUI() callOrganizationApi() callOrganisationDetailsApi() - getAllDataAgreementRecords() } func setupUI(){ @@ -331,7 +330,7 @@ extension BBConsentOrganisationViewController: UITableViewDelegate, UITableViewD if record?.count ?? 0 > 0, record?[0].optIn == false { consentedCount = 0 totalCount = 0 - } else if record?.count == 0 { + } else if record?.count == 0 || record?.count == nil { consentedCount = 0 totalCount = 0 } @@ -422,12 +421,13 @@ extension BBConsentOrganisationViewController: WebServiceTaskManagerProtocol { } else if serviceManager.serviceType == .OrgDetails { if let data = response.data?.responseModel as? OrganisationDetails { organisaionDeatils = data + getAllDataAgreementRecords() orgTableView.reloadData() } } else if serviceManager.serviceType == .GetDataAgreementRecords { if let data = response.data?.responseModel as? DataAgreementRecords { records = data - let dataAgreementIDs = organisaionDeatils?.purposeConsents?.map({ $0.iD }) ?? [] + let dataAgreementIDs = organisaionDeatils?.purposeConsents?.filter({ $0.lawfulUsage == false }).map({ $0.iD ?? "" }) ?? [] let idsWithAttributeRecords = records?.consentRecords?.map({ $0.dataAgreementId }) ?? [] for item in dataAgreementIDs { @@ -436,11 +436,13 @@ extension BBConsentOrganisationViewController: WebServiceTaskManagerProtocol { // Create add record api call let serviceManager = OrganisationWebServiceManager() serviceManager.managerDelegate = self - serviceManager.createDataAgreementRecord(dataAgreementId: item ?? "") + serviceManager.createDataAgreementRecord(dataAgreementId: item) } } orgTableView.reloadData() } + } else if serviceManager.serviceType == .CreateDataAgreementRecord { + getAllDataAgreementRecords() } } @@ -487,6 +489,8 @@ extension BBConsentOrganisationViewController: ExpandableLabelDelegate ,PurposeC let filteredRecord = self.records?.consentRecords?.map({ $0 }).filter({ $0.dataAgreementId == self.organisaionDeatils?.purposeConsents?[cell.tag].iD }) if filteredRecord?.count ?? 0 > 0 { serviceManager.updatePurpose(dataAgreementRecordId: filteredRecord?[0].id ?? "", dataAgreementId: filteredRecord?[0].dataAgreementId ?? "", status: status) + } else { + serviceManager.createDataAgreementRecord(dataAgreementId: self.organisaionDeatils?.purposeConsents?[cell.tag].iD ?? "") } })); } diff --git a/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/Cell/BBConsentDashboardUsagePurposeCell.swift b/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/Cell/BBConsentDashboardUsagePurposeCell.swift index c455890..bdc34a8 100644 --- a/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/Cell/BBConsentDashboardUsagePurposeCell.swift +++ b/PrivacyDashboardiOS/Classes/ViewControllers/DashBoardViewController/Cell/BBConsentDashboardUsagePurposeCell.swift @@ -33,12 +33,17 @@ class BBConsentDashboardUsagePurposeCell: UITableViewCell { func showData() { self.statusSwitch.isOn = self.swictOn ? true : false - self.statusSwitch.isEnabled = consentInfo?.lawfulUsage ?? false ? true : false + if consentInfo?.lawfulUsage ?? false == true { + self.statusSwitch.isEnabled = true + } else { + self.statusSwitch.isEnabled = false + self.statusSwitch.isOn = true + } self.titleLbl.text = self.consentInfo?.name - var valueString = "Allow " if consentedCount ?? 0 > 0 { + var valueString = "Allow " valueString.append(": ") let consentedStr = String(consentedCount ?? 0) valueString.append(consentedStr) diff --git a/PrivacyDashboardiOS/Classes/WebService/Application API/OrganisationApi/OrganisationWebService.swift b/PrivacyDashboardiOS/Classes/WebService/Application API/OrganisationApi/OrganisationWebService.swift index a720037..ceb7e37 100644 --- a/PrivacyDashboardiOS/Classes/WebService/Application API/OrganisationApi/OrganisationWebService.swift +++ b/PrivacyDashboardiOS/Classes/WebService/Application API/OrganisationApi/OrganisationWebService.swift @@ -32,7 +32,7 @@ class OrganisationWebService: BBConsentBaseWebService { } func organisationDetails(orgId : String){ - self.url = baseUrl + "/service/data-agreements?offset=1&limit=500" + self.url = baseUrl + "/service/data-agreements?offset=0&limit=500" getServiceCall() } @@ -42,7 +42,7 @@ class OrganisationWebService: BBConsentBaseWebService { } func dataAgreementRecords() { - self.url = baseUrl + "/service/individual/record/consent-record?offset=1&limit=500" + self.url = baseUrl + "/service/individual/record/consent-record?offset=0&limit=500" getServiceCall() }