mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Support per user track changes (proof of concept)
This commit is contained in:
parent
6c1efec564
commit
710c89a629
7 changed files with 124 additions and 33 deletions
|
@ -278,7 +278,7 @@ module.exports = ProjectController =
|
||||||
pdfViewer : user.ace.pdfViewer
|
pdfViewer : user.ace.pdfViewer
|
||||||
syntaxValidation: user.ace.syntaxValidation
|
syntaxValidation: user.ace.syntaxValidation
|
||||||
}
|
}
|
||||||
trackChangesEnabled: !!project.track_changes
|
trackChangesState: project.track_changes
|
||||||
showTrackChangesOnboarding: !!showTrackChangesOnboarding
|
showTrackChangesOnboarding: !!showTrackChangesOnboarding
|
||||||
privilegeLevel: privilegeLevel
|
privilegeLevel: privilegeLevel
|
||||||
chatUrl: Settings.apis.chat.url
|
chatUrl: Settings.apis.chat.url
|
||||||
|
|
|
@ -32,7 +32,7 @@ ProjectSchema = new Schema
|
||||||
archived : { type: Boolean }
|
archived : { type: Boolean }
|
||||||
deletedDocs : [DeletedDocSchema]
|
deletedDocs : [DeletedDocSchema]
|
||||||
imageName : { type: String }
|
imageName : { type: String }
|
||||||
track_changes : { type: Boolean }
|
track_changes : { type: Object }
|
||||||
|
|
||||||
ProjectSchema.statics.getProject = (project_or_id, fields, callback)->
|
ProjectSchema.statics.getProject = (project_or_id, fields, callback)->
|
||||||
if project_or_id._id?
|
if project_or_id._id?
|
||||||
|
|
|
@ -106,7 +106,7 @@ block requirejs
|
||||||
//- We need to do .replace(/\//g, '\\/') do that '</script>' -> '<\/script>'
|
//- We need to do .replace(/\//g, '\\/') do that '</script>' -> '<\/script>'
|
||||||
//- and doesn't prematurely end the script tag.
|
//- and doesn't prematurely end the script tag.
|
||||||
script#data(type="application/json").
|
script#data(type="application/json").
|
||||||
!{JSON.stringify({userSettings: userSettings, user: user}).replace(/\//g, '\\/')}
|
!{JSON.stringify({userSettings: userSettings, user: user, trackChangesState: trackChangesState}).replace(/\//g, '\\/')}
|
||||||
|
|
||||||
script(type="text/javascript").
|
script(type="text/javascript").
|
||||||
window.data = JSON.parse($("#data").text());
|
window.data = JSON.parse($("#data").text());
|
||||||
|
@ -118,7 +118,7 @@ block requirejs
|
||||||
window.csrfToken = "!{csrfToken}";
|
window.csrfToken = "!{csrfToken}";
|
||||||
window.anonymous = #{anonymous};
|
window.anonymous = #{anonymous};
|
||||||
window.maxDocLength = #{maxDocLength};
|
window.maxDocLength = #{maxDocLength};
|
||||||
window.trackChangesEnabled = #{trackChangesEnabled};
|
window.trackChangesState = data.trackChangesState;
|
||||||
window.showTrackChangesOnboarding = #{!!showTrackChangesOnboarding};
|
window.showTrackChangesOnboarding = #{!!showTrackChangesOnboarding};
|
||||||
window.wikiEnabled = #{!!(settings.apis.wiki && settings.apis.wiki.url)};
|
window.wikiEnabled = #{!!(settings.apis.wiki && settings.apis.wiki.url)};
|
||||||
window.requirejs = {
|
window.requirejs = {
|
||||||
|
|
|
@ -46,21 +46,46 @@
|
||||||
is-loading="reviewPanel.dropdown.loading"
|
is-loading="reviewPanel.dropdown.loading"
|
||||||
permissions="permissions"
|
permissions="permissions"
|
||||||
)
|
)
|
||||||
span.review-panel-toolbar-label(ng-if="permissions.write")
|
div
|
||||||
span(ng-click="toggleTrackChanges(true)", ng-if="editor.wantTrackChanges === false") !{translate("track_changes_is_off")}
|
span On for everyone
|
||||||
span(ng-click="toggleTrackChanges(false)", ng-if="editor.wantTrackChanges === true") !{translate("track_changes_is_on")}
|
|
||||||
review-panel-toggle(
|
review-panel-toggle(
|
||||||
ng-if="editor.wantTrackChanges == editor.trackChanges"
|
ng-model="reviewPanel.trackChangesOnForEveryone"
|
||||||
ng-model="editor.wantTrackChanges"
|
on-toggle="toggleTrackChangesForEveryone"
|
||||||
on-toggle="toggleTrackChanges"
|
|
||||||
disabled="!project.features.trackChanges"
|
disabled="!project.features.trackChanges"
|
||||||
on-disabled-click="openTrackChangesUpgradeModal"
|
on-disabled-click="openTrackChangesUpgradeModal"
|
||||||
)
|
)
|
||||||
span.review-panel-toolbar-label.review-panel-toolbar-label-disabled(ng-if="!permissions.write")
|
div
|
||||||
span(ng-if="editor.wantTrackChanges === false") !{translate("track_changes_is_off")}
|
span You {{user.id}}
|
||||||
span(ng-if="editor.wantTrackChanges === true") !{translate("track_changes_is_on")}
|
//- Missing on-toggle attribute because we also need to pass user_id to the toggleTrackChangesForUser
|
||||||
span.review-panel-toolbar-spinner(ng-if="editor.wantTrackChanges != editor.trackChanges")
|
//- method, and it's not clear how.
|
||||||
i.fa.fa-spin.fa-spinner
|
review-panel-toggle(
|
||||||
|
ng-model="reviewPanel.trackChangesState[user.id]"
|
||||||
|
disabled="!project.features.trackChanges"
|
||||||
|
on-disabled-click="openTrackChangesUpgradeModal"
|
||||||
|
)
|
||||||
|
div(ng-repeat="member in project.members")
|
||||||
|
span {{member.email}} {{member._id}}
|
||||||
|
review-panel-toggle(
|
||||||
|
ng-model="reviewPanel.trackChangesState[member._id]"
|
||||||
|
disabled="!project.features.trackChanges"
|
||||||
|
on-disabled-click="openTrackChangesUpgradeModal"
|
||||||
|
)
|
||||||
|
|
||||||
|
//- span.review-panel-toolbar-label(ng-if="permissions.write")
|
||||||
|
//- span(ng-click="toggleTrackChanges(true)", ng-if="editor.wantTrackChanges === false") !{translate("track_changes_is_off")}
|
||||||
|
//- span(ng-click="toggleTrackChanges(false)", ng-if="editor.wantTrackChanges === true") !{translate("track_changes_is_on")}
|
||||||
|
//- review-panel-toggle(
|
||||||
|
//- ng-if="editor.wantTrackChanges == editor.trackChanges"
|
||||||
|
//- ng-model="editor.wantTrackChanges"
|
||||||
|
//- on-toggle="toggleTrackChanges"
|
||||||
|
//- disabled="!project.features.trackChanges"
|
||||||
|
//- on-disabled-click="openTrackChangesUpgradeModal"
|
||||||
|
//- )
|
||||||
|
//- span.review-panel-toolbar-label.review-panel-toolbar-label-disabled(ng-if="!permissions.write")
|
||||||
|
//- span(ng-if="editor.wantTrackChanges === false") !{translate("track_changes_is_off")}
|
||||||
|
//- span(ng-if="editor.wantTrackChanges === true") !{translate("track_changes_is_on")}
|
||||||
|
//- span.review-panel-toolbar-spinner(ng-if="editor.wantTrackChanges != editor.trackChanges")
|
||||||
|
//- i.fa.fa-spin.fa-spinner
|
||||||
|
|
||||||
.rp-entry-list(
|
.rp-entry-list(
|
||||||
review-panel-sorted
|
review-panel-sorted
|
||||||
|
|
|
@ -37,10 +37,6 @@ define [
|
||||||
@$scope.$watch "editor.wantTrackChanges", (value) =>
|
@$scope.$watch "editor.wantTrackChanges", (value) =>
|
||||||
return if !value?
|
return if !value?
|
||||||
@_syncTrackChangesState(@$scope.editor.sharejs_doc)
|
@_syncTrackChangesState(@$scope.editor.sharejs_doc)
|
||||||
|
|
||||||
@$scope.$watch "project.features.trackChanges", (trackChangesFeature) =>
|
|
||||||
return if !trackChangesFeature?
|
|
||||||
@$scope.editor.wantTrackChanges = window.trackChangesEnabled and trackChangesFeature
|
|
||||||
|
|
||||||
autoOpenDoc: () ->
|
autoOpenDoc: () ->
|
||||||
open_doc_id =
|
open_doc_id =
|
||||||
|
|
|
@ -11,7 +11,10 @@ define [
|
||||||
CUR_FILE : "cur_file"
|
CUR_FILE : "cur_file"
|
||||||
OVERVIEW : "overview"
|
OVERVIEW : "overview"
|
||||||
|
|
||||||
|
window.reviewPanel = # DEBUG LINE
|
||||||
$scope.reviewPanel =
|
$scope.reviewPanel =
|
||||||
|
trackChangesState: {}
|
||||||
|
trackChangesOnForEveryone: false
|
||||||
entries: {}
|
entries: {}
|
||||||
resolvedComments: {}
|
resolvedComments: {}
|
||||||
hasEntries: false
|
hasEntries: false
|
||||||
|
@ -565,24 +568,90 @@ define [
|
||||||
|
|
||||||
$scope.gotoEntry = (doc_id, entry) ->
|
$scope.gotoEntry = (doc_id, entry) ->
|
||||||
ide.editorManager.openDocId(doc_id, { gotoOffset: entry.offset })
|
ide.editorManager.openDocId(doc_id, { gotoOffset: entry.offset })
|
||||||
|
|
||||||
|
applyTrackChangesStateToClient = (state) ->
|
||||||
|
console.log "[applyTrackChangesStateToClient]", state
|
||||||
|
if typeof state is "boolean"
|
||||||
|
console.log "[applyTrackChangesStateToClient]", "BOOLEAN"
|
||||||
|
$scope.reviewPanel.trackChangesOnForEveryone = state
|
||||||
|
$scope.reviewPanel.trackChangesState = {}
|
||||||
|
$scope.editor.wantTrackChanges = state
|
||||||
|
else
|
||||||
|
$scope.reviewPanel.trackChangesOnForEveryone = false
|
||||||
|
$scope.reviewPanel.trackChangesState = state
|
||||||
|
# State is an object with user_ids as keys
|
||||||
|
if state[ide.$scope.user.id]
|
||||||
|
$scope.editor.wantTrackChanges = true
|
||||||
|
else
|
||||||
|
$scope.editor.wantTrackChanges = false
|
||||||
|
|
||||||
$scope.toggleTrackChanges = (value) ->
|
applyClientTrackChangesStateToServer = () ->
|
||||||
|
if $scope.reviewPanel.trackChangesOnForEveryone
|
||||||
|
data = {on : true}
|
||||||
|
else
|
||||||
|
data = {on_for: $scope.reviewPanel.trackChangesState}
|
||||||
|
console.log "[applyClientTrackChangesStateToServer]", data
|
||||||
|
data._csrf = window.csrfToken
|
||||||
|
$http.post "/project/#{$scope.project_id}/track_changes", data
|
||||||
|
|
||||||
|
setTrackChangesState = (state) ->
|
||||||
|
console.log "[setTrackChangesState]", state
|
||||||
if $scope.project.features.trackChanges
|
if $scope.project.features.trackChanges
|
||||||
$scope.editor.wantTrackChanges = value
|
applyTrackChangesStateToClient(state)
|
||||||
$http.post "/project/#{$scope.project_id}/track_changes", {_csrf: window.csrfToken, on: value}
|
applyClientTrackChangesStateToServer()
|
||||||
event_tracking.sendMB "rp-trackchanges-toggle", { value }
|
event_tracking.sendMB "rp-trackchanges-toggle", { state }
|
||||||
else
|
else
|
||||||
$scope.openTrackChangesUpgradeModal()
|
$scope.openTrackChangesUpgradeModal()
|
||||||
|
|
||||||
$scope.toggleTrackChangesFromKbdShortcut = () ->
|
|
||||||
if $scope.editor.wantTrackChanges
|
|
||||||
$scope.toggleTrackChanges false
|
|
||||||
else
|
|
||||||
$scope.toggleTrackChanges true
|
|
||||||
|
|
||||||
ide.socket.on "toggle-track-changes", (value) ->
|
$scope.toggleTrackChangesForEveryone = (onForEveryone) ->
|
||||||
|
console.log "[toggleTrackChangesForEveryone]", onForEveryone
|
||||||
|
setTrackChangesState(onForEveryone)
|
||||||
|
|
||||||
|
window.toggleTrackChangesForUser = # DEBUG LINE
|
||||||
|
$scope.toggleTrackChangesForUser = (user_id) ->
|
||||||
|
state = $scope.reviewPanel.trackChangesState
|
||||||
|
if state[user_id]?
|
||||||
|
delete state[user_id]
|
||||||
|
else
|
||||||
|
state[user_id] = true
|
||||||
|
setTrackChangesState(state)
|
||||||
|
|
||||||
|
ide.socket.on "toggle-track-changes", (state) ->
|
||||||
|
console.log "[ide toggle-track-changes]", state
|
||||||
$scope.$apply () ->
|
$scope.$apply () ->
|
||||||
$scope.editor.wantTrackChanges = value
|
applyTrackChangesStateToClient(state)
|
||||||
|
|
||||||
|
# window.toggleTrackChangesForUser = # DEBUG LINE, remove after dev
|
||||||
|
# $scope.toggleTrackChangesForUser = (user_id) ->
|
||||||
|
# state = $scope.reviewPanel.trackChangesState
|
||||||
|
# if state == true
|
||||||
|
# return # On for everyone, nothing to do
|
||||||
|
# else if state == false or !state?
|
||||||
|
# state = {}
|
||||||
|
#
|
||||||
|
# if state[user_id]
|
||||||
|
# delete state[user_id]
|
||||||
|
# else
|
||||||
|
# state[user_id] = true
|
||||||
|
# setTrackChangesState(state)
|
||||||
|
|
||||||
|
# Not sure what the kbd shortcut should do now?
|
||||||
|
# $scope.toggleTrackChangesFromKbdShortcut = () ->
|
||||||
|
# if $scope.editor.wantTrackChanges
|
||||||
|
# $scope.toggleTrackChanges false
|
||||||
|
# else
|
||||||
|
# $scope.toggleTrackChanges true
|
||||||
|
|
||||||
|
_inited = false
|
||||||
|
ide.$scope.$on "project:joined", () ->
|
||||||
|
console.log "project joined, setting track changes state from window"
|
||||||
|
return if _inited
|
||||||
|
project = ide.$scope.project
|
||||||
|
if project.features.trackChanges
|
||||||
|
applyTrackChangesStateToClient(window.trackChangesState)
|
||||||
|
else
|
||||||
|
applyTrackChangesStateToClient(false)
|
||||||
|
_inited = true
|
||||||
|
|
||||||
_refreshingRangeUsers = false
|
_refreshingRangeUsers = false
|
||||||
_refreshedForUserIds = {}
|
_refreshedForUserIds = {}
|
||||||
|
|
|
@ -124,14 +124,15 @@
|
||||||
.review-panel-toolbar {
|
.review-panel-toolbar {
|
||||||
display: none;
|
display: none;
|
||||||
.rp-size-expanded & {
|
.rp-size-expanded & {
|
||||||
display: flex;
|
display: block;
|
||||||
|
// display: flex; TODO
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
position: relative;
|
position: relative;
|
||||||
height: @rp-toolbar-height;
|
// height: @rp-toolbar-height; TODO
|
||||||
border-bottom: 1px solid @rp-border-grey;
|
border-bottom: 1px solid @rp-border-grey;
|
||||||
background-color: @rp-bg-dim-blue;
|
background-color: @rp-bg-dim-blue;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
Loading…
Reference in a new issue