Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #169: First time user glitch for optIn values #170

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class BBConsentOrganisationViewController: BBConsentBaseViewController {
setupUI()
callOrganizationApi()
callOrganisationDetailsApi()
getAllDataAgreementRecords()
}

func setupUI(){
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
}
}

Expand Down Expand Up @@ -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 ?? "")
}
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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()
}

Expand Down
Loading