Skip to content

Commit

Permalink
Merge pull request #3938 from crazyserver/MOBILE-4329
Browse files Browse the repository at this point in the history
Mobile 4329
  • Loading branch information
dpalou authored Feb 27, 2024
2 parents 94f7711 + 9e0b1d4 commit 60e256e
Show file tree
Hide file tree
Showing 50 changed files with 1,669 additions and 217 deletions.
1 change: 1 addition & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
"@core_comments"
"@core_course"
"@core_courses"
"@core_dataprivacy"
"@core_grades"
"@core_login"
"@core_mainmenu"
Expand Down
34 changes: 34 additions & 0 deletions scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,40 @@
"core.courses.totalcoursesearchresults": "local_moodlemobileapp",
"core.currentdevice": "local_moodlemobileapp",
"core.custom": "form",
"core.dataprivacy.cancelrequest": "tool_dataprivacy",
"core.dataprivacy.cancelrequestconfirmation": "tool_dataprivacy",
"core.dataprivacy.contactdataprotectionofficer": "tool_dataprivacy",
"core.dataprivacy.createnewdatarequest": "tool_dataprivacy",
"core.dataprivacy.datarequests": "tool_dataprivacy",
"core.dataprivacy.daterequested": "tool_dataprivacy",
"core.dataprivacy.deletemyaccount": "tool_dataprivacy",
"core.dataprivacy.message": "tool_dataprivacy",
"core.dataprivacy.newrequest": "tool_dataprivacy",
"core.dataprivacy.nodatarequests": "tool_dataprivacy",
"core.dataprivacy.pluginname": "tool_dataprivacy",
"core.dataprivacy.replyto": "tool_dataprivacy",
"core.dataprivacy.requestactions": "tool_dataprivacy",
"core.dataprivacy.requestby": "tool_dataprivacy",
"core.dataprivacy.requestcomments": "tool_dataprivacy",
"core.dataprivacy.requeststatus": "tool_dataprivacy",
"core.dataprivacy.requestsubmitted": "tool_dataprivacy",
"core.dataprivacy.requesttype": "tool_dataprivacy",
"core.dataprivacy.requesttype_help": "tool_dataprivacy",
"core.dataprivacy.requesttypedelete": "tool_dataprivacy",
"core.dataprivacy.requesttypeexport": "tool_dataprivacy",
"core.dataprivacy.requesttypeothers": "tool_dataprivacy",
"core.dataprivacy.send": "tool_dataprivacy",
"core.dataprivacy.statusapproved": "tool_dataprivacy",
"core.dataprivacy.statusawaitingapproval": "tool_dataprivacy",
"core.dataprivacy.statuscancelled": "tool_dataprivacy",
"core.dataprivacy.statuscomplete": "tool_dataprivacy",
"core.dataprivacy.statusdeleted": "tool_dataprivacy",
"core.dataprivacy.statusexpired": "tool_dataprivacy",
"core.dataprivacy.statuspending": "tool_dataprivacy",
"core.dataprivacy.statuspreprocessing": "tool_dataprivacy",
"core.dataprivacy.statusprocessing": "tool_dataprivacy",
"core.dataprivacy.statusready": "tool_dataprivacy",
"core.dataprivacy.statusrejected": "tool_dataprivacy",
"core.datastoredoffline": "local_moodlemobileapp",
"core.date": "moodle",
"core.datecreated": "repository",
Expand Down
4 changes: 2 additions & 2 deletions src/addons/badges/services/handlers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { Injectable } from '@angular/core';
import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
import {
CoreUserDelegateContext,
CoreUserDelegateService,
CoreUserProfileHandler,
CoreUserProfileHandlerData,
CoreUserProfileHandlerType,
} from '@features/user/services/user-delegate';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
Expand All @@ -33,7 +33,7 @@ export class AddonBadgesUserHandlerService implements CoreUserProfileHandler {

name = 'AddonBadges:fakename'; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext.
priority = 300;
type = CoreUserDelegateService.TYPE_NEW_PAGE;
type = CoreUserProfileHandlerType.LIST_ITEM;

/**
* @inheritdoc
Expand Down
4 changes: 2 additions & 2 deletions src/addons/blog/services/handlers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import {
CoreUserProfileHandler,
CoreUserProfileHandlerData,
CoreUserDelegateService,
CoreUserProfileHandlerType,
CoreUserDelegateContext,
} from '@features/user/services/user-delegate';
import { CoreNavigator } from '@services/navigator';
Expand All @@ -32,7 +32,7 @@ export class AddonBlogUserHandlerService implements CoreUserProfileHandler {

name = 'AddonBlog'; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext.
priority = 200;
type = CoreUserDelegateService.TYPE_NEW_PAGE;
type = CoreUserProfileHandlerType.LIST_ITEM;

/**
* @inheritdoc
Expand Down
4 changes: 2 additions & 2 deletions src/addons/competency/services/handlers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { COURSE_PAGE_NAME } from '@features/course/course.module';
import { CoreUserProfile } from '@features/user/services/user';
import {
CoreUserProfileHandler,
CoreUserDelegateService,
CoreUserProfileHandlerType,
CoreUserProfileHandlerData,
CoreUserDelegateContext,
} from '@features/user/services/user-delegate';
Expand All @@ -36,7 +36,7 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler

name = 'AddonCompetency'; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext.
priority = 100;
type = CoreUserDelegateService.TYPE_NEW_PAGE;
type = CoreUserProfileHandlerType.LIST_ITEM;
cacheEnabled = true;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/addons/coursecompletion/services/handlers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreUserProfile } from '@features/user/services/user';
import {
CoreUserProfileHandler,
CoreUserDelegateService,
CoreUserProfileHandlerType,
CoreUserProfileHandlerData,
CoreUserDelegateContext,
} from '@features/user/services/user-delegate';
Expand All @@ -31,7 +31,7 @@ import { AddonCourseCompletion } from '../coursecompletion';
export class AddonCourseCompletionUserHandlerService implements CoreUserProfileHandler {

name = 'AddonCourseCompletion:viewCompletion';
type = CoreUserDelegateService.TYPE_NEW_PAGE;
type = CoreUserProfileHandlerType.LIST_ITEM;
priority = 350;
cacheEnabled = true;

Expand Down
8 changes: 6 additions & 2 deletions src/addons/messages/services/handlers/user-send-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
import { Injectable } from '@angular/core';
import { Params } from '@angular/router';
import { CoreUserProfile } from '@features/user/services/user';
import { CoreUserDelegateService, CoreUserProfileHandler, CoreUserProfileHandlerData } from '@features/user/services/user-delegate';
import {
CoreUserProfileHandlerType,
CoreUserProfileHandler,
CoreUserProfileHandlerData,
} from '@features/user/services/user-delegate';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
import { makeSingleton } from '@singletons';
Expand All @@ -29,7 +33,7 @@ export class AddonMessagesSendMessageUserHandlerService implements CoreUserProfi

name = 'AddonMessages:sendMessage';
priority = 1000;
type = CoreUserDelegateService.TYPE_COMMUNICATION;
type = CoreUserProfileHandlerType.BUTTON;

/**
* @inheritdoc
Expand Down
4 changes: 2 additions & 2 deletions src/addons/notes/services/handlers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreUserProfile } from '@features/user/services/user';
import {
CoreUserProfileHandler,
CoreUserDelegateService,
CoreUserProfileHandlerType,
CoreUserProfileHandlerData,
CoreUserDelegateContext,
} from '@features/user/services/user-delegate';
Expand All @@ -33,7 +33,7 @@ export class AddonNotesUserHandlerService implements CoreUserProfileHandler {

name = 'AddonNotes:notes';
priority = 250;
type = CoreUserDelegateService.TYPE_NEW_PAGE;
type = CoreUserProfileHandlerType.LIST_ITEM;
cacheEnabled = true;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/addons/privatefiles/services/handlers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { AddonPrivateFiles } from '@addons/privatefiles/services/privatefiles';
import { makeSingleton } from '@singletons';
import {
CoreUserDelegateContext,
CoreUserDelegateService,
CoreUserProfileHandlerType,
CoreUserProfileHandler,
CoreUserProfileHandlerData,
} from '@features/user/services/user-delegate';
Expand All @@ -36,7 +36,7 @@ export class AddonPrivateFilesUserHandlerService implements CoreUserProfileHandl

name = 'AddonPrivateFiles';
priority = 400;
type = CoreUserDelegateService.TYPE_NEW_PAGE;
type = CoreUserProfileHandlerType.LIST_ITEM;
cacheEnabled = true;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/empty-box/empty-box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

:host {
--image-size: 120px;
--icon-color: var(--text-color);
--icon-color: var(--subdued-text-color);

display: flex;
flex-direction: column;
Expand Down
33 changes: 33 additions & 0 deletions src/core/features/dataprivacy/components/components.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { NgModule } from '@angular/core';
import { CoreSharedModule } from '@/core/shared.module';
import { CoreDataPrivacyContactDPOComponent } from './contactdpo/contactdpo';
import { CoreDataPrivacyNewRequestComponent } from './newrequest/newrequest';

@NgModule({
declarations: [
CoreDataPrivacyContactDPOComponent,
CoreDataPrivacyNewRequestComponent,
],
imports: [
CoreSharedModule,
],
exports: [
CoreDataPrivacyContactDPOComponent,
CoreDataPrivacyNewRequestComponent,
],
})
export class CoreDataPrivacyComponentsModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<ion-header>
<ion-toolbar>
<ion-title>
<h1>{{ 'core.dataprivacy.contactdataprotectionofficer' | translate }}</h1>
</ion-title>
<ion-buttons slot="end">
<ion-button fill="clear" (click)="close()" [attr.aria-label]="'core.close' | translate">
<ion-icon slot="icon-only" name="fas-xmark" aria-hidden="true" />
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<form [formGroup]="form" name="contactDPO" (ngSubmit)="send($event)">
<ion-item *ngIf="email">
<ion-label>
<p class="item-heading">
{{ 'core.dataprivacy.replyto' | translate }}
</p>
<p>{{ email }}</p>
</ion-label>
</ion-item>
<ion-item>
<ion-textarea labelPlacement="floating" placeholder="{{ 'core.dataprivacy.message' | translate }}" rows="5"
[(ngModel)]="message" name="text" [required]="true" formControlName="message">
<div [core-mark-required]="true" slot="label">
{{ 'core.dataprivacy.message' | translate }}
</div>
</ion-textarea>
</ion-item>
</form>
</ion-content>
<ion-footer slot="fixed" class="ion-padding">
<ion-button expand="block" (click)="send($event)" [disabled]="!form.valid">
{{ 'core.dataprivacy.send' | translate }}
</ion-button>
</ion-footer>
94 changes: 94 additions & 0 deletions src/core/features/dataprivacy/components/contactdpo/contactdpo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { CoreDataPrivacy } from '@features/dataprivacy/services/dataprivacy';
import { CoreUser } from '@features/user/services/user';
import { CoreSites } from '@services/sites';
import { CoreDomUtils, ToastDuration } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';

import { ModalController } from '@singletons';

/**
* Component that displays the contact DPO page.
*/
@Component({
selector: 'core-data-privacy-contact-dpo',
templateUrl: 'contactdpo.html',
})
export class CoreDataPrivacyContactDPOComponent implements OnInit {

message = '';
email = '';

// Form variables.
form: FormGroup;

constructor(
protected fb: FormBuilder,
) {
this.form = new FormGroup({});

// Initialize form variables.
this.form.addControl('message', this.fb.control('', Validators.required));
}

/**
* @inheritdoc
*/
async ngOnInit(): Promise<void> {
const modal = await CoreDomUtils.showModalLoading();

// Get current user email.
const userId = CoreSites.getCurrentSiteUserId();
const user = await CoreUtils.ignoreErrors(CoreUser.getProfile(userId));

this.email = user?.email || '';

modal.dismiss();
}

/**
* Sends the message.
*/
async send(event: Event): Promise<void> {
event.preventDefault();
event.stopPropagation();

const modal = await CoreDomUtils.showModalLoading();

try {
// Send the message.
const succeed = await CoreDataPrivacy.contactDPO(this.message);
if (succeed) {
CoreDomUtils.showToast('core.dataprivacy.requestsubmitted', true, ToastDuration.LONG);
ModalController.dismiss(true);
}
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'Error sending data privacy request');
} finally {
modal.dismiss();
}
}

/**
* Close modal.
*/
close(): void {
ModalController.dismiss();
}

}
Loading

0 comments on commit 60e256e

Please sign in to comment.