Skip to content

Commit 0b6c660

Browse files
committed
wip allow project sharing checkbox
1 parent fe8c2aa commit 0b6c660

File tree

9 files changed

+29
-12
lines changed

9 files changed

+29
-12
lines changed

src/Api/Model/Scriptureforge/Sfchecks/Command/SfchecksProjectCommands.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class SfchecksProjectCommands
2121
* @throws \Exception
2222
* @return string projectId
2323
*/
24-
public static function updateProject($projectId, $userId, $object)
24+
public static function updateSfChecksProject($projectId, $userId, $object)
2525
{
2626
$project = new SfchecksProjectModel($projectId);
2727
ProjectCommands::checkIfArchivedAndThrow($project);

src/Api/Model/Shared/Command/SessionCommands.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ public static function getSessionData($projectId, $userId, $website, $mockFilena
7171
$sessionData['project']['ownerRef']['username'] = $ownerUserModel->username;
7272

7373
$sessionData['project']['userIsProjectOwner'] = $project->isOwner($userId);
74+
$sessionData['project']['allowSharing'] = $project->allowSharing;
7475
$sessionData['project']['slug'] = $project->databaseName();
7576
$sessionData['project']['isArchived'] = $project->isArchived;
7677
$sessionData['project']['interfaceLanguageCode'] = $project->interfaceLanguageCode;
7778
$sessionData['project']['inviteToken']['token'] = $project->inviteToken->token;
7879
$sessionData['project']['inviteToken']['defaultRole'] = $project->inviteToken->defaultRole;
7980
$sessionData['userProjectRights'] = $project->getRightsArray($userId);
8081
$sessionData['userProjectRole'] = $project->users[$userId]->role;
82+
$sessionData['userIsProjectMember'] = $project->userIsMember($userId);
8183
$sessionData['projectSettings'] = $project->getPublicSettings($userId);
8284
}
8385
}

src/Api/Model/Shared/ProjectModel.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function __construct($id = '')
3939
return new ProjectRoleModel();
4040
});
4141

42+
$this->allowSharing = false;
43+
4244
$this->userJoinRequests = new MapOf(function() {
4345
return new ProjectRoleModel();
4446
});
@@ -109,6 +111,9 @@ public function __construct($id = '')
109111
/** @var ProjectUserPropertiesSettings */
110112
public $userProperties;
111113

114+
/** @var boolean When true, non-manager project members can access the sharing dialog */
115+
public $allowSharing;
116+
112117
/**
113118
* Specifies which site this project belongs to e.g. scriptureforge || languageforge, cf. Website class
114119
* @var string

src/Site/views/languageforge/container/languageforge.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<breadcrumbs id="top" class="breadcrumbs d-none d-md-block"></breadcrumbs>
104104
</div>
105105
<ul class="nav navbar-nav">
106-
<li class='nav-item' ng-if="$ctrl.header.settings.length > 0 && $ctrl.currentUserIsProjectManager">
106+
<li class='nav-item' ng-if="$ctrl.header.settings.length > 0 && $ctrl.displayShareButton">
107107
<a id="shareBtn" class="btn btn-primary my-auto" title="Share" href="#"
108108
ng-click="$ctrl.openShareWithOthersModal()">
109109
<i class="fa fa-share-alt iconPadding"></i><span>Share</span>

src/angular-app/bellows/core/navbar.controller.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import * as angular from 'angular';
22

33
import {InterfaceConfig} from '../shared/model/interface-config.model';
44
import {ProjectSettings} from '../shared/model/project-settings.model';
5-
import {ProjectRoles} from '../shared/model/project.model';
5+
import {ProjectRoles, Project} from '../shared/model/project.model';
66
import {ProjectService, ProjectTypeNames} from './api/project.service';
77
import {ApplicationHeaderService, HeaderData} from './application-header.service';
88
import {ModalService} from './modal/modal.service';
99
import {OfflineCacheUtilsService} from './offline/offline-cache-utils.service';
10-
import {SessionService} from './session.service';
10+
import {SessionService, Session} from './session.service';
1111

1212
interface Rights {
1313
canCreateProject: boolean;
@@ -17,8 +17,10 @@ export class NavbarController implements angular.IController {
1717
rights: Rights = {} as Rights;
1818
projectTypesBySite: () => string[];
1919
header: HeaderData;
20+
session: Session;
2021
interfaceConfig: InterfaceConfig;
2122
currentUserIsProjectManager: boolean;
23+
displayShareButton: boolean;
2224
projectTypeNames: ProjectTypeNames;
2325
siteName: string;
2426

@@ -36,6 +38,7 @@ export class NavbarController implements angular.IController {
3638
this.projectTypesBySite = this.projectService.data.projectTypesBySite;
3739
this.header = this.applicationHeaderService.data;
3840
this.sessionService.getSession().then(session => {
41+
this.session = session;
3942
const defaultInterfaceConfig =
4043
{
4144
direction: 'ltr',
@@ -61,6 +64,9 @@ export class NavbarController implements angular.IController {
6164
}
6265
}
6366
this.currentUserIsProjectManager = session.data.userProjectRole === ProjectRoles.MANAGER.key;
67+
const project: Project = this.session.data.project;
68+
this.displayShareButton =
69+
(this.currentUserIsProjectManager || (project.allowSharing && this.session.data.userIsProjectMember));
6470
this.rights.canCreateProject =
6571
session.hasSiteRight(this.sessionService.domain.PROJECTS, this.sessionService.operation.CREATE);
6672
this.siteName = session.baseSite();

src/angular-app/bellows/core/session.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class SessionData {
6767
userSiteRights: any;
6868
userProjectRights: any;
6969
userProjectRole: string;
70+
userIsProjectMember: boolean;
7071
accessToken: string;
7172
version: string;
7273
}

src/angular-app/bellows/shared/model/project.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface Project {
77
projectName: string;
88
role: string;
99
anonymousUserRole: string;
10-
reusableInviteLinkRole: string;
10+
allowSharing: boolean;
1111
siteName: string;
1212
type?: string;
1313
isArchived: boolean;

src/angular-app/languageforge/lexicon/shared/share-with-others/share-with-others.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as angular from 'angular';
2+
import { ProjectService } from '../../../../bellows/core/api/project.service';
23
import { Session, SessionService } from '../../../../bellows/core/session.service';
34
import { Project } from '../../../../bellows/shared/model/project.model';
5+
import { LexiconProjectService } from '../../core/lexicon-project.service';
46

57
export class ShareWithOthersModalInstanceController implements angular.IController {
68
modalInstance: any;
@@ -9,8 +11,9 @@ export class ShareWithOthersModalInstanceController implements angular.IControll
911
project: Project;
1012
session: Session;
1113

12-
static $inject = ['sessionService'];
13-
constructor(private readonly sessionService: SessionService) {}
14+
static $inject = ['lexProjectService', 'sessionService'];
15+
constructor(private readonly lexProjectService: LexiconProjectService,
16+
private readonly sessionService: SessionService) {}
1417

1518
$onInit(): void {
1619
this.sessionService.getSession().then(session => {
@@ -20,7 +23,7 @@ export class ShareWithOthersModalInstanceController implements angular.IControll
2023
}
2124

2225
setProjectSharability(): void {
23-
console.log('TODO: actually set project.allowSharing = ' + this.allowSharing);
26+
this.lexProjectService.updateProject({allowSharing: this.allowSharing});
2427
}
2528

2629
setProjectListability(): void {

src/angular-app/languageforge/lexicon/shared/share-with-others/share-with-others.modal.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ <h3 class="modal-title">Share with Others</h3>
66
<div class="modal-body">
77
<user-management project="$ctrl.project" session="$ctrl.session"></user-management>
88

9-
<!-- <div id="sharing-checkboxes" class="form-group">
9+
<div id="sharing-checkboxes" class="form-group">
1010
<div class="form-check">
1111
<input class="form-check-input" type="checkbox" value="" id="sharing-check-1" ng-model="$ctrl.allowSharing" ng-change="$ctrl.setProjectSharability()">
1212
<label class="form-check-label" for="sharing-check-1">
1313
Allow others to share <i class="fa fa-share-alt"></i>
1414
</label>
1515
</div>
16-
<div class="form-check">
16+
<!-- <div class="form-check">
1717
<input class="form-check-input" type="checkbox" value="" id="sharing-check-2" ng-model="$ctrl.listProject" ng-change="$ctrl.setProjectListability()">
1818
<label class="form-check-label" for="sharing-check-2">
1919
Project is publicly listed on languageforge.org
2020
</label>
21-
</div>
22-
</div> -->
21+
</div> -->
22+
</div>
2323
</div>
2424
<div class="modal-footer d-block clearfix">
2525
<button class="btn btn-primary float-right" id="apply-sharing-config-button" ng-click="$ctrl.close()">

0 commit comments

Comments
 (0)