...
 
Commits (4)
/* Controllers */
root.controller('DashboardCtrl', ['$scope', '$http', '$stateParams', '$location', '$rightFactory', '$languageFactory', '$skillsFactory', '$eventsFactory', '$navigationFactory', '$activitiesFactory', '$state', '$projectFactory', '$userFactory', '$tasksFactory', function ($scope, $http, $stateParams, $location, $rightFactory, $languageFactory, $skillsFactory, $eventsFactory, $navigationFactory, $activitiesFactory, $state, $projectFactory, $userFactory, $tasksFactory) {
root.controller('DashboardCtrl', ['$scope', '$http', '$stateParams', '$location', '$rightFactory', '$languageFactory', '$skillsFactory', '$eventsFactory', '$navigationFactory', '$activitiesFactory', '$state', '$projectFactory', '$userFactory', '$tasksFactory', '$chatEventsFactory', function ($scope, $http, $stateParams, $location, $rightFactory, $languageFactory, $skillsFactory, $eventsFactory, $navigationFactory, $activitiesFactory, $state, $projectFactory, $userFactory, $tasksFactory, $chatEventsFactory) {
$scope.activities = [];
$scope.discussions = [];
......@@ -61,9 +61,8 @@ root.controller('DashboardCtrl', ['$scope', '$http', '$stateParams', '$location'
}
$scope.manageDiscussions = function (activity) {
$chatEventsFactory.promptNewDiscussion()
console.log(activity);
}
$chatEventsFactory.promptNewDiscussion({activity : activity, prompt : "newFromActivity"});
};
$scope.getTasks = function () {
......
......@@ -176,7 +176,7 @@ root.controller('ProjectOverviewCtrl', ['$scope', '$state', '$http', '$statePara
projectCtrl.startDiscussion = function () {
$chatEventsFactory.promptNewDiscussion($scope._getProject());
$chatEventsFactory.promptNewDiscussion({ projectId : $scope._getProject(), prompt : "newFromProject"});
}
projectCtrl.onReady();
......
......@@ -301,7 +301,7 @@ root.controller('PortfolioCtrl', ['$scope', '$http', '$stateParams', '$rightFact
function startDiscussion() {
$chatEventsFactory.promptNewDiscussion($scope._getProject());
$chatEventsFactory.promptNewDiscussion({ projectId : $scope._getProject(), prompt : "newFromProject"});
}
......
......@@ -54,27 +54,28 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
chatCtrl.closePopup = function () {
chatCtrl.newElement.firstMessage="";
$chatEventsFactory.promptCancel();
}
chatCtrl.newDiscussion = function () {
//Récupération des membres de la discussion
var members = chatCtrl.newElement.listRecipients.map(function (e) {
return e.id
});
if(chatCtrl.newElement.visibility == "project"){
var projectId = $(projectSelected).val();
} else {
var projectId = 0;
members.push(session.user);
var projectId = 0;
// Si on a un projetId on le récupère
if(chatCtrl.newElement.projectId ){
projectId=chatCtrl.newElement.projectId;
}
var discussion = {ownerId: session.user, projectId: projectId, label: chatCtrl.newElement.label, members : members};
var discussion = {ownerId: session.user, projectId: projectId, label: chatCtrl.newElement.label, members : members, content : chatCtrl.newElement.firstMessage};
//angular.copy(chatCtrl.newElement,discussion);
discussion.attachment = chatCtrl.newElement.attachment;
$chatFactory.addDiscussion(discussion);
......@@ -85,6 +86,76 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
chatCtrl.init = function (params) {
chatCtrl.params = params;
// Si on a projectId, on précharge la liste des membres cas : newFromActivity et newFromProject
if (params.projectId) {
$projectFactory.get_project_projectMembers(params.projectId, function (data) {
if (data.status == "success") {
chatCtrl.newElement.listRecipients = data.details;
}
})
}
$scope.$watch('chatCtrl.newElement.visibility', function(value) {
if(value == "project"){
chatCtrl.getProjectMembers();
} else {
chatCtrl.newElement.listRecipients = {};
}
});
chatCtrl.labelTitle = params.labelTitle;
//TODO modfier pour voir ce que ça fait
chatCtrl.showType = false;
switch (params.prompt) {
case "newFromActivity":
chatCtrl.editLabelDiscussion = false;
chatCtrl.showVisibility = false;
chatCtrl.newElement = $chatModelFactory.newElement;
chatCtrl.newElement.projectId = params.projectId;
chatCtrl.editPopupDiscussion = true;
break;
case "newFromProject":
chatCtrl.editLabelDiscussion = false;
chatCtrl.showVisibility = false;
chatCtrl.newElement = $chatModelFactory.newElement;
chatCtrl.newElement.projectId = params.projectId;
chatCtrl.editPopupDiscussion = true;
break;
case "newFromRightMenu":
chatCtrl.editLabelDiscussion = true;
chatCtrl.showVisibility = true;
chatCtrl.newElement = $chatModelFactory.newElement;
chatCtrl.editPopupDiscussion = true;
//On charge les projets
$serverFactory.runCommand("get_user_project", {}, function (data) {
chatCtrl.projects = data.details;
});
break;
case "update" :
chatCtrl.editLabelDiscussion = true;
chatCtrl.showVisibility = false;
chatCtrl.newElement = $chatModelFactory.model.currentDiscussion;
chatCtrl.editPopupDiscussion = true;
break;
}
/*
//projectId? labelTitle showFirstMessage
chatCtrl.params = params;
chatCtrl.editLabelDiscussion = true;
......@@ -113,7 +184,7 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
chatCtrl.params.portfolioId = data.details[0].parentProject;
}
})*/
chatCtrl.showVisibility = false;
/* chatCtrl.showVisibility = false;
$projectFactory.get_project_projectMembers(params.projectId, function (data) {
if (data.status == "success") {
......@@ -130,11 +201,11 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
$serverFactory.runCommand("get_user_project", {}, function (data) {
chatCtrl.projects = data.details;
console.log("projects", chatCtrl.projects)
});
});*/
}
function removeRecipient(recipient) {
chatCtrl.removeRecipient = function(recipient) {
var index = $scope._arrayObjectIndexOf(chatCtrl.newElement.listRecipients, recipient.label, "label");
if (index > -1) {
chatCtrl.newElement.listRecipients.splice(index, 1);
......@@ -151,8 +222,8 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
chatCtrl.getProjectMembers = function () {
console.log('projectId ' + $(projectSelected).val());
var projectId = $(projectSelected).val();
// console.log('projectId ' + $(projectSelected).val());
var projectId = chatCtrl.projectSelected;
$projectFactory.get_project_projectMembers(projectId, function (data) {
if (data.status == "success") {
console.log(data);
......
......@@ -38,8 +38,8 @@
<label class="small">
<input name="radioVisibility" type="radio" ng-model="chatCtrl.newElement.visibility"
value="project"> {{::_labels.chatProject}}
<select id= "projectSelected" ng-change="chatCtrl.getProjectMembers()" ng-model="chatCtrl.projects" ng-if="chatCtrl.newElement.visibility=='project'" class="inline">
<option ng-repeat="prj in chatCtrl.projects track by prj.id" value="{{prj.id}}">{{prj.fullName}} </option>
<select id= "projectSelected" ng-change="chatCtrl.getProjectMembers()" ng-model="chatCtrl.projectSelected" ng-if="chatCtrl.newElement.visibility=='project'" class="inline">
<option ng-repeat="prj in chatCtrl.projects track by prj.id " value="{{prj.id}}">{{prj.fullName}} </option>
</select>
</label>
</div>
......@@ -68,7 +68,7 @@
<div class="borders">
<div class='jt-editor' style='height: 100px;overflow-y: auto;overflow-x: hidden;'>
<div class="row row-members">
<div ng-repeat="recipient in chatCtrl.newElement.listRecipients track by $index"
<div ng-repeat="recipient in chatCtrl.newElement.listRecipients track by recipient.id"
style="display:inline-block; padding: 5px">
<!--<img width="30" height="30" ng-src="{{recipient['avatar']?recipient['avatar']:_urls.defaultAvatar}}">-->
<user user="recipient" size="30" label="true" label-position="'right'"></user>
......@@ -90,7 +90,7 @@
</div>
<p ng-if="!chatCtrl.editPopupDiscussion">{{::_labels.chatNotOwner}}</p>
<div class="form-group has-error" ng-if="chatCtrl.editPopupDiscussion && chatCtrl.showVisibility == true">
<div class="form-group has-error" ng-if="chatCtrl.editPopupDiscussion">
<label>{{::_labels.firstMessage}}</label><span class="required-item"> *</span>
<textarea type="text" style="height:120px;" required ng-model="chatCtrl.newElement.firstMessage"></textarea>
</div>
......
......@@ -31,8 +31,8 @@ root.controller('ChatWindowsContainerCtrl', ['$scope', '$chatFactory', "$chatEve
chatWindowsCtrl.loadMoreMessages = function (discussion, nbElements) {
var beginIndex = discussion.elements[0].id;
$chatFactory.getDiscussionsElements(discussionId, nbElements, beginIndex, true);
var beginIndex = discussion.messages[0].id;
$chatFactory.getDiscussionsElements(discussion.id, nbElements, beginIndex, true);
}
......@@ -93,26 +93,35 @@ root.controller('ChatWindowsContainerCtrl', ['$scope', '$chatFactory', "$chatEve
$chatEventsFactory.onPromptNewDiscussion($scope, function (params) {
if (params.attachment) {
params.labelTitle = $languageFactory._labels.newDiscussionAbout;
$chatModelFactory.newElement = {attachment: params.attachment};
params.showFirstMessage = true;
if (params.attachment.projectId) {
switch (params.prompt) {
case "newFromActivity":
params.projectId = params.attachment.projectId;
}
} else {
params.labelTitle = $languageFactory._labels.newDiscussionAbout;
params.projectId = params.activity.project.id;
params.showFirstMessage = true;
if(params.activity.elementId && params.activity.section && params.projectId){
$chatModelFactory.newElement.attachment = {
id: params.activity.elementId,
type: params.activity.section,
projectId : params.projectId,
}
}
break;
case "newFromProject":
params.labelTitle = $languageFactory._labels.newDiscussion;
$chatModelFactory.newElement.listRecipients = [{
"id": $rightFactory.session.userId,
"label": $rightFactory.session.userLabel,
"avatar": $rightFactory.session.userAvatar
}]
case "newFromRightMenu":
params.labelTitle = $languageFactory._labels.newDiscussion;
/* $chatModelFactory.newElement.listRecipients = [{
"id": $rightFactory.session.userId,
"label": $rightFactory.session.userLabel,
"avatar": $rightFactory.session.userAvatar
}];*/
break;
}
......@@ -129,6 +138,8 @@ root.controller('ChatWindowsContainerCtrl', ['$scope', '$chatFactory', "$chatEve
});
$languageFactory.onInitLang($scope, init, true);
}]);
......
......@@ -9,7 +9,7 @@ root.controller('ListDiscussionsCtrl', ['$scope', '$chatEventsFactory', '$chatFa
listDiscussionsCtrl.newDiscussion = function () {
$chatEventsFactory.promptNewDiscussion();
$chatEventsFactory.promptNewDiscussion({projectId : 0 , prompt : "newFromRightMenu"});
}
......
......@@ -2,7 +2,7 @@
<h4>
{{::_labels.myDiscussions}}
{{::_labels.myDiscussions}} (Beta)
</h4>
......
......@@ -153,11 +153,9 @@ function $chatEventsFactory($rootScope, $chatModelFactory, $chatFactory) {
};
returns.promptNewDiscussion = function (projectId) {
returns.promptNewDiscussion = function (params) {
$rootScope.$broadcast(PROMPT_NEW_DISCUSSION, {
projectId : projectId
});
$rootScope.$broadcast(PROMPT_NEW_DISCUSSION, params);
};
returns.onPromptNewDiscussion = function ($scope, handler) {
......
......@@ -60,29 +60,30 @@ angular.module('myApp.filters', []).filter('interpolate', ['version', function (
return $sce.trustAsHtml(string);
}
}]).filter('keylength', function () {
return function (input) {
if (!angular.isObject(input)) {
return 0;
//throw Error("Usage of non-objects with keylength filter!!")
return function (input) {
if (!angular.isObject(input)) {
return 0;
//throw Error("Usage of non-objects with keylength filter!!")
}
return Object.keys(input).length;
}
return Object.keys(input).length;
}
}).filter('newlines', function () {
return function (text) {
if (text) return text.replace(/\n/g, '<br/>');
else return text;
}
}).filter('formatUTF8', function () {
return function (text) {
if (text) return text.replace(/u00e0/g, "à").replace(/u00e9/g, "é").replace(/u00e8/g, "è").replace(/u00ea/g, "ê").replace(/u00e7/g, "ç").replace(/u0027/g, "'").replace(/u2019/g, "'").replace(/u00ab/g, '"').replace(/u00bb/g, '"').replace(/u2026/g, "...").replace(/u2026/g, "œ").replace(/u00e2/g, "â"); //
else return text;
}
}).filter('userShortName', ['$utilsFactory', function ($utilsFactory) {
return function (user) {
return $utilsFactory.formatUser(user).shortName;
}
}]).filter('userAvatar', ['$utilsFactory', function ($utilsFactory) {
return function (user) {
return user.avatar ? user.avatar : $utilsFactory.defaultThumbnail("user");
}
}]);
}).filter('newlines', function () {
return function (text) {
if (text) return text.replace(/\n/g, '<br/>');
else return text;
}
}).filter('formatUTF8', function () {
return function (text) {
if (text) return text.replace(/u00e0/g, "à").replace(/u00e9/g, "é").replace(/u00e8/g, "è").replace(/u00ea/g, "ê").replace(/u00e7/g, "ç").replace(/u0027/g, "'").replace(/u2019/g, "'").replace(/u00ab/g, '"').replace(/u00bb/g, '"').replace(/u2026/g, "...").replace(/u2026/g, "œ").replace(/u00e2/g, "â"); //
else return text;
}
}).filter('userShortName', ['$utilsFactory', function ($utilsFactory) {
return function (user) {
return $utilsFactory.formatUser(user).shortName;
}
}]).filter('userAvatar', ['$utilsFactory', function ($utilsFactory) {
return function (user) {
return user.avatar ? user.avatar : $utilsFactory.defaultThumbnail("user");
}
}]);