Correct Writer navigation and add book-scoped working objectives with guided onboarding
This commit is contained in:
parent
58ee48d94a
commit
a0c2367dd9
69
PlotLine.Tests/Browser/writer-onboarding-live.cjs
Normal file
69
PlotLine.Tests/Browser/writer-onboarding-live.cjs
Normal file
@ -0,0 +1,69 @@
|
||||
// Explicit Development acceptance only. Requires a disposable author and owned fixture.
|
||||
// Credentials remain in a private file and are never logged.
|
||||
const {chromium}=require('playwright');
|
||||
const fs=require('node:fs');
|
||||
const assert=require('node:assert/strict');
|
||||
(async()=>{
|
||||
const identityPath=process.env.PD_WRITER_IDENTITY,scopePath=process.env.PD_WRITER_SCOPE,output=process.env.PD_WRITER_SCREENSHOTS;
|
||||
assert(identityPath?.startsWith('/tmp/pd-dev-browser-writer2-')&&scopePath&&output,'Dedicated fixture files required');
|
||||
const who=JSON.parse(fs.readFileSync(identityPath)),scope=JSON.parse(fs.readFileSync(scopePath));
|
||||
assert(who.Database==='PlotDirector_Development'&&/^pwa-browser-.*@example\.invalid$/.test(who.Email));
|
||||
for(const key of ['project','book','chapter','scene','other'])assert(Number.isSafeInteger(scope[key])&&scope[key]>0);
|
||||
const base='https://dev.plotdirector.com',writer=`${base}/Writer?projectId=${scope.project}&bookId=${scope.book}`;
|
||||
const browser=await chromium.launch();
|
||||
try{for(const pwa of [false,true]){
|
||||
const context=await browser.newContext({viewport:{width:1440,height:1000}});
|
||||
if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));
|
||||
const page=await context.newPage();
|
||||
await page.goto(base+'/Account/Login');await page.locator('[name=Email]').fill(who.Email);await page.locator('[name=Password]').fill(who.Password);
|
||||
await Promise.all([page.waitForURL('**/Projects'),page.locator('button[type=submit]').click()]);
|
||||
await page.goto(writer);
|
||||
if(!pwa){
|
||||
assert.equal(await page.getByRole('heading',{name:'Start Here',exact:true}).isVisible(),true);
|
||||
await page.screenshot({path:output+'/Overview-Initial.png',fullPage:true});
|
||||
await page.getByRole('link',{name:/Explore your manuscript/}).click();await page.waitForURL(`**/Books/Details/${scope.book}#chapters`);
|
||||
assert.equal(await page.locator('#chapters').isVisible(),true);assert.equal(await page.getByRole('link',{name:'The crossing',exact:true}).count(),1);
|
||||
await page.getByRole('link',{name:'The crossing',exact:true}).click();
|
||||
await page.waitForURL(`**/Chapters/Details/${scope.chapter}`);assert((await page.locator('body').textContent()).includes('Arrival'));
|
||||
await page.goto(writer);await page.getByRole('link',{name:/Continue an existing manuscript/}).click();
|
||||
await page.locator('[name=Activity]').selectOption('Revising');await page.locator('[data-objective-chapter]').selectOption(String(scope.chapter));await page.locator('[data-objective-scene]').selectOption(String(scope.scene));
|
||||
await Promise.all([page.waitForURL(`**/Writer?bookId=${scope.book}`),page.getByRole('button',{name:'Save objective · start without a schedule'}).click()]);
|
||||
}
|
||||
assert.equal(await page.getByRole('heading',{name:'Continue Writing',exact:true}).isVisible(),true);
|
||||
assert((await page.locator('.writer-current').textContent()).includes('Revising'));
|
||||
if(!pwa)await page.screenshot({path:output+'/Overview-Objective.png',fullPage:true});
|
||||
await page.getByRole('link',{name:'Continue Writing',exact:true}).click();await page.waitForURL(`**/Scenes/Edit/${scope.scene}`);
|
||||
assert((await page.locator('body').textContent()).includes('Arrival'));
|
||||
await page.goto(writer);await page.getByRole('link',{name:'Open Chapters',exact:true}).click();await page.waitForURL(`**/Books/Details/${scope.book}#chapters`);assert.equal(await page.locator('#chapters').isVisible(),true);
|
||||
await page.goto(writer);await page.getByRole('link',{name:'Create a writing plan',exact:true}).click();await page.waitForURL('**/Writer/ScheduleSetup?*');
|
||||
assert.equal(await page.locator('[name=BookID]').inputValue(),String(scope.book));assert.equal(await page.locator('[name=ProjectID]').inputValue(),String(scope.project));
|
||||
assert((await page.locator('[name=BookID]').textContent()).includes('All Books'));
|
||||
await page.getByRole('link',{name:'Skip scheduling · return to Writer'}).click();assert.equal(await page.getByRole('heading',{name:'Continue Writing',exact:true}).isVisible(),true);
|
||||
if(!pwa){
|
||||
for(const allBooks of [false,true]){
|
||||
await page.goto(`${base}/Writer/ScheduleSetup?projectId=${scope.project}&bookId=${scope.book}`);
|
||||
await page.locator('[name=PlanName]').fill(allBooks?'Synthetic project-wide plan':'Synthetic book plan');
|
||||
if(allBooks)await page.locator('[name=BookID]').selectOption('');
|
||||
await Promise.all([page.waitForURL('**/Writer/SchedulePreview?writingPlanId=*'),page.getByRole('button',{name:'Create Plan and Generate Schedule'}).click()]);
|
||||
await page.getByRole('link',{name:'Edit Plan',exact:true}).click();await page.waitForURL('**/Writer/EditWritingPlan?writingPlanId=*');
|
||||
assert((await page.locator('body').textContent()).includes(allBooks?'All Books':'Writer verification book'));
|
||||
await page.locator('[name=PlanName]').fill(allBooks?'Updated project-wide plan':'Updated book plan');
|
||||
await Promise.all([page.waitForURL('**/Writer/WritingPlans?*'),page.getByRole('button',{name:'Save Plan',exact:true}).click()]);
|
||||
assert((await page.locator('body').textContent()).includes(allBooks?'Updated project-wide plan':'Updated book plan'));
|
||||
}
|
||||
await page.goto(`${base}/Writer/WritingPlans?projectId=${scope.project}&bookId=${scope.book}`);
|
||||
assert((await page.locator('body').textContent()).includes('Updated project-wide plan'));
|
||||
assert((await page.locator('body').textContent()).includes('Updated book plan'));
|
||||
}
|
||||
for(const title of ['Writing Journey','Writing Plan','Workspaces','Reports']){
|
||||
await page.goto(writer);const link=page.locator('#ribbon-panel-writer a').filter({hasText:new RegExp('^'+title+'$')});
|
||||
assert.equal(await link.count(),1);await link.click();await page.waitForLoadState();assert.equal(await page.locator('h1').count(),1);assert(!(await page.locator('body').textContent()).includes('An error occurred'));
|
||||
assert(new URL(page.url()).searchParams.get('bookId')===String(scope.book),`${title} retains book`);
|
||||
}
|
||||
await page.goto(`${base}/Writer?projectId=${scope.project}&bookId=${scope.other}`);assert.equal(await page.getByRole('heading',{name:'Start Here',exact:true}).isVisible(),true);
|
||||
await page.goto(writer);assert.equal(await page.getByRole('heading',{name:'Continue Writing',exact:true}).isVisible(),true);
|
||||
await page.getByRole('link',{name:'Change objective'}).click();assert.equal(await page.locator('[name=Activity]').inputValue(),'Revising');assert.equal(await page.locator('[data-objective-scene]').inputValue(),String(scope.scene));
|
||||
console.log(`PASS live Writer author journey: ${pwa?'simulated PWA':'browser'}; real chapter/scene destinations, saved objective, optional scheduling, ribbon and book isolation`);
|
||||
await context.close();
|
||||
}}finally{await browser.close();}
|
||||
})().catch(error=>{console.error(error.message);process.exitCode=1;});
|
||||
@ -12,7 +12,7 @@ const base='http://127.0.0.1:5238';
|
||||
let negotiations=0;
|
||||
await page.route('**/hubs/word-companion-follow/negotiate?*',route=>++negotiations===1?route.fulfill({status:503,body:'Transient fixture outage'}):route.continue());
|
||||
await page.goto(base+'/fixture?page=writer&layout=full');
|
||||
await page.waitForFunction(()=>document.querySelector('[data-writing-workspace-word]').textContent==='Unavailable');
|
||||
await page.waitForFunction(()=>document.querySelector('[data-writing-workspace-word]').textContent==='Status unavailable');
|
||||
assert.equal(negotiations,1,'No tight retry loop after initial network failure');
|
||||
await page.locator('#display-setup > summary').click();
|
||||
assert.equal(await page.locator('[data-start-writing-workspace]').isVisible(),false,'A disconnected book has no linked-Word controls');
|
||||
|
||||
@ -10,6 +10,15 @@ const fs=require('node:fs');
|
||||
await page.setViewportSize({width,height:1000});await page.addInitScript(theme=>localStorage.setItem('plotdirector.applicationTheme',theme),theme);
|
||||
await page.goto(`http://127.0.0.1:5238/writer2-fixture?populated=${populated}`);
|
||||
assert.equal(await page.locator('h1').textContent(),'A Distant Shore');
|
||||
assert.equal(await page.getByRole('heading',{name:'Start Here',exact:true}).isVisible(),true);
|
||||
assert.equal(await page.locator('.writer-start-paths a').count(),3);
|
||||
assert((await page.getByRole('link',{name:/Explore your manuscript/}).getAttribute('href')).includes('/Books/Details/12#chapters'));
|
||||
await page.getByRole('link',{name:/Continue an existing manuscript/}).click();
|
||||
await page.locator('[data-objective-chapter]').selectOption('21');
|
||||
await page.locator('[data-objective-scene]').selectOption('31');
|
||||
assert.equal(await page.locator('[data-objective-scene] option[value="32"]').evaluate(option=>option.disabled),true);
|
||||
await page.locator('[data-objective-chapter]').selectOption('22');
|
||||
assert.equal(await page.locator('[data-objective-scene]').inputValue(),'');
|
||||
assert.equal(await page.locator('.pd-ribbon-navigation').filter({hasText:/^Writer$/}).count(),1);
|
||||
assert.equal(await page.locator('#ribbon-panel-writer').isVisible(),true);
|
||||
assert.equal(await page.locator('.writer-tabs a').count(),5);
|
||||
@ -17,14 +26,23 @@ const fs=require('node:fs');
|
||||
const choices=await page.locator('[data-app-book-choice]').evaluateAll(nodes=>nodes.map(n=>n.getAttribute('href')));assert(choices.length>0);assert(choices.every(href=>new URL(href,'http://127.0.0.1:5238').pathname==='/Writer'),'Common book selection stays in Writer');
|
||||
assert.equal(await page.locator('[data-start-writing-workspace]').isVisible(),false,'No linked document exposes no workspace reapply action');
|
||||
assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth+2),false,`${theme} ${width} overflow`);
|
||||
await page.locator('.writer-queue-details > summary').click();
|
||||
assert.equal(await page.locator('[data-writer-queue="WriteNext"]').isVisible(),true);
|
||||
assert.equal(await page.locator('[data-writer-queue="Revision"]').isVisible(),false);
|
||||
if(populated){assert.equal(await page.locator('.writer-day').count(),28);assert.equal(await page.locator('.writer-day-observed').count(),2);assert.equal(await page.locator('.writer-indicators strong').nth(0).textContent(),'120');assert((await page.locator('.writer-day-observed').first().getAttribute('href')).includes('day='));}
|
||||
else{assert((await page.locator('.writer-empty').textContent()).includes('Earlier writing'));assert.equal(await page.locator('.writer-indicators strong').first().textContent(),'—');}
|
||||
if(populated){assert.equal(await page.locator('.writer-day').count(),28);assert.equal(await page.locator('.writer-day-observed').count(),2);assert((await page.locator('.writer-activity-graphic').textContent()).includes('+120'));assert((await page.locator('.writer-day-observed').first().getAttribute('href')).includes('day='));}
|
||||
else{assert((await page.locator('.writer-progress .writer-empty').textContent()).includes('Earlier writing'));assert.equal(await page.locator('.writer-activity-graphic').count(),0);}
|
||||
await page.getByRole('link',{name:'Connection & Display Setup'}).click();await page.waitForFunction(()=>document.getElementById('display-setup').open);assert.equal(await page.locator('#display-setup').getAttribute('open'),'');
|
||||
if(theme==='warm-light'&&width===1440&&populated&&!pwa)await page.screenshot({path:'/home/nick/writer2-sprint/writer2-desktop.png',fullPage:true});
|
||||
if(theme==='warm-light'&&width===390&&populated&&!pwa)await page.screenshot({path:'/home/nick/writer2-sprint/writer2-small.png',fullPage:true});
|
||||
if(theme==='warm-light'&&width===1440&&populated&&!pwa)await page.screenshot({path:'/home/nick/writer2-correction/overview-initial.png',fullPage:true});
|
||||
if(theme==='warm-light'&&width===390&&populated&&!pwa)await page.screenshot({path:'/home/nick/writer2-correction/overview-small.png',fullPage:true});
|
||||
}
|
||||
await page.goto('http://127.0.0.1:5238/writer2-fixture?objective=true');
|
||||
assert.equal(await page.getByRole('heading',{name:'Continue Writing',exact:true}).isVisible(),true);
|
||||
assert((await page.getByRole('link',{name:'Continue Writing',exact:true}).getAttribute('href')).includes('/Scenes/Edit/31'));
|
||||
for(const state of [{connected:true,linked:false,text:'Connected · no linked manuscript open'},{connected:true,linked:true,text:'Connected · linked manuscript open'},{connected:false,linked:false,text:'Disconnected'}]){
|
||||
await page.evaluate(state=>{const leases=state.linked?[{bookId:12,wordAvailable:true}]:[];leases.connectionState=state.connected?'Connected':'Disconnected';window.dispatchEvent(new CustomEvent('native-companion-presence',{detail:leases}));},state);
|
||||
assert.equal(await page.locator('[data-writing-workspace-word]').textContent(),state.text);
|
||||
}
|
||||
if(!pwa)await page.screenshot({path:'/home/nick/writer2-correction/overview-objective.png',fullPage:true});
|
||||
assert.deepEqual(errors,[]);await context.close();
|
||||
}
|
||||
console.log('PASS Writer 2 overview: real Razor, 48 theme/viewport/history/PWA combinations, single navigation, book scope, honest empty states, chart links and contextual controls.');
|
||||
|
||||
42
PlotLine.Tests/Sql/WriterWorkingObjective.sql
Normal file
42
PlotLine.Tests/Sql/WriterWorkingObjective.sql
Normal file
@ -0,0 +1,42 @@
|
||||
-- Run only on the explicitly provisioned disposable correction copy. Fixtures roll back.
|
||||
USE [PlotDirector_WriterCorrection_20261115];
|
||||
GO
|
||||
SET NOCOUNT ON;
|
||||
SET XACT_ABORT OFF;
|
||||
BEGIN TRANSACTION;
|
||||
DECLARE @l int,@u int,@other int,@p int,@b int,@foreign int,@c int,@scene int;
|
||||
INSERT dbo.AppUser(Email,DisplayName,PasswordHash) VALUES(CONVERT(nvarchar(36),NEWID())+'@objective.invalid','Synthetic Objective','not-a-credential'); SET @u=SCOPE_IDENTITY();
|
||||
INSERT dbo.AppUser(Email,DisplayName,PasswordHash) VALUES(CONVERT(nvarchar(36),NEWID())+'@objective.invalid','Other Objective','not-a-credential'); SET @other=SCOPE_IDENTITY();
|
||||
INSERT dbo.SubscriptionLevel(Name,DisplayName,MaxBooks,MaxChaptersPerBook,MaxScenesPerBook,MaxCharactersPerProject,MaxStorageMB,MaxCollaborators,SortOrder,RequiresStripeSubscription) VALUES(CONVERT(nvarchar(36),NEWID()),'Objective fixture',10,100,100,100,100,0,0,0); SET @l=SCOPE_IDENTITY();
|
||||
INSERT dbo.UserSubscription(UserID,SubscriptionLevelID,IsActive,IsTrial,TrialExpiryDateUTC) VALUES(@u,@l,1,1,'2030-01-01');
|
||||
INSERT dbo.Projects(ProjectName) VALUES('Synthetic objective'); SET @p=SCOPE_IDENTITY();
|
||||
INSERT dbo.ProjectUserAccess(ProjectID,UserID,AccessRole,IsActive) VALUES(@p,@u,'Owner',1);
|
||||
INSERT dbo.Books(ProjectID,BookTitle,BookNumber,SortOrder) VALUES(@p,'Objective book',1,1); SET @b=SCOPE_IDENTITY();
|
||||
INSERT dbo.Books(ProjectID,BookTitle,BookNumber,SortOrder) VALUES(@p,'Other book',2,2); SET @foreign=SCOPE_IDENTITY();
|
||||
INSERT dbo.Chapters(BookID,ChapterTitle,ChapterNumber,SortOrder,RevisionStatusID) VALUES(@b,'Objective chapter',1,1,(SELECT TOP(1) RevisionStatusID FROM dbo.RevisionStatuses ORDER BY SortOrder)); SET @c=SCOPE_IDENTITY();
|
||||
INSERT dbo.Scenes(ChapterID,SceneTitle,SceneNumber,SortOrder,RevisionStatusID,TimeModeID,TimeConfidenceID) VALUES(@c,'Objective scene',1,1,(SELECT TOP(1) RevisionStatusID FROM dbo.RevisionStatuses ORDER BY SortOrder),(SELECT TOP(1) TimeModeID FROM dbo.TimeModes ORDER BY SortOrder),(SELECT TOP(1) TimeConfidenceID FROM dbo.TimeConfidences ORDER BY SortOrder)); SET @scene=SCOPE_IDENTITY();
|
||||
EXEC dbo.WriterObjective @u,@b,'save',@c,@scene,'Revising';
|
||||
IF NOT EXISTS(SELECT 1 FROM dbo.WriterWorkingObjectives WHERE BookID=@b AND UserID=@u AND ChapterID=@c AND SceneID=@scene AND Activity='Revising') THROW 51001,'Objective not persisted',1;
|
||||
PRINT 'PASS objective book/chapter/scene and revision intention persist';
|
||||
EXEC dbo.WriterObjective @u,@b,'save',NULL,NULL,'Drafting';
|
||||
IF (SELECT COUNT(*) FROM dbo.WriterWorkingObjectives WHERE BookID=@b AND UserID=@u)<>1 THROW 51001,'Duplicate objective',1;
|
||||
PRINT 'PASS revisiting updates one objective without requiring a chapter or plan';
|
||||
BEGIN TRY EXEC dbo.WriterObjective @other,@b,'save',NULL,NULL,'Drafting'; THROW 51001,'Foreign access accepted',1; END TRY BEGIN CATCH IF ERROR_NUMBER()<>51000 THROW; END CATCH;
|
||||
PRINT 'PASS unauthorised author refused';
|
||||
BEGIN TRY EXEC dbo.WriterObjective @u,@foreign,'save',@c,@scene,'Revising'; THROW 51001,'Foreign chapter accepted',1; END TRY BEGIN CATCH IF ERROR_NUMBER()<>51000 THROW; END CATCH;
|
||||
PRINT 'PASS cross-book chapter refused';
|
||||
BEGIN TRY EXEC dbo.WriterObjective @u,@b,'save',NULL,@scene,'Revising'; THROW 51001,'Unparented scene accepted',1; END TRY BEGIN CATCH IF ERROR_NUMBER()<>51000 THROW; END CATCH;
|
||||
PRINT 'PASS scene requires matching chapter';
|
||||
BEGIN TRY EXEC dbo.WriterObjective @u,@b,'save',NULL,NULL,'Invented'; THROW 51001,'Invalid activity accepted',1; END TRY BEGIN CATCH IF ERROR_NUMBER()<>51000 THROW; END CATCH;
|
||||
PRINT 'PASS unsupported activity refused';
|
||||
-- Read ignores a removed chapter so the author can select a replacement.
|
||||
EXEC dbo.WriterObjective @u,@b,'save',@c,@scene,'Editing';
|
||||
UPDATE dbo.Chapters SET IsArchived=1 WHERE ChapterID=@c;
|
||||
EXEC dbo.WriterObjective @u,@b,'read';
|
||||
PRINT 'PASS read tolerates archived working target';
|
||||
DELETE dbo.Scenes WHERE SceneID=@scene;
|
||||
DELETE dbo.Chapters WHERE ChapterID=@c;
|
||||
DELETE dbo.Books WHERE BookID=@b;
|
||||
IF EXISTS(SELECT 1 FROM dbo.WriterWorkingObjectives WHERE BookID=@b) THROW 51001,'Book deletion blocked or orphaned',1;
|
||||
PRINT 'PASS objective follows existing permanent book cleanup';
|
||||
ROLLBACK;
|
||||
@ -171,6 +171,9 @@ internal static class ToolbarBrowserHost
|
||||
app.UseWritingSolverReviewBoundary();
|
||||
app.MapGet("/writer2-fixture",async (HttpContext context)=>{
|
||||
var model=WriterFixture();
|
||||
model.Book = new(){BookID=12,ProjectID=7,BookTitle="A Distant Shore",ChapterCount=3,SceneCount=7,CurrentWordCount=12400};
|
||||
model.ObjectiveChoices=[new(){ChapterID=21,ChapterTitle="The crossing",SceneID=31,SceneTitle="Arrival"},new(){ChapterID=22,ChapterTitle="The harbour",SceneID=32,SceneTitle="Departure"}];
|
||||
if(context.Request.Query["objective"]=="true") model.Objective=new(){BookID=12,ChapterID=21,SceneID=31,Activity="Revising",ChapterTitle="The crossing",SceneTitle="Arrival"};
|
||||
if(context.Request.Query["populated"]=="true")
|
||||
{
|
||||
var now=DateTime.UtcNow;
|
||||
|
||||
@ -12,7 +12,7 @@ internal static class WriterDashboardTests
|
||||
void Check(bool value,string message){if(!value)throw new Exception(message);Console.WriteLine("PASS Writer dashboard "+message);}
|
||||
int? scheduledBook=null;var allowed=true;
|
||||
var workspace=Proxy<IWriterWorkspaceService>((method,args)=>method=="GetDashboardAsync"?Task.FromResult(new WriterDashboardViewModel{ProjectID=1,WriteNext=[new(){BookID=2,SceneID=20},new(){BookID=3,SceneID=30}]}):throw new Exception(method));
|
||||
var schedule=Proxy<IWritingScheduleService>((method,args)=>{if(method!="GetTodayDashboardAsync")throw new Exception(method);scheduledBook=(int?)args![1];return Task.FromResult(new WritingScheduleDashboardViewModel{TodayTasks=[new(){BookID=2,SceneID=20},new(){BookID=3,SceneID=30}]});});
|
||||
var schedule=Proxy<IWritingScheduleService>((method,args)=>{if(method=="GetScheduleSetupAsync")return Task.FromResult(new WritingScheduleSetupViewModel{ProjectID=(int?)args![0]});if(method=="PopulateScheduleSetupOptionsAsync")return Task.CompletedTask;if(method!="GetTodayDashboardAsync")throw new Exception(method);scheduledBook=(int?)args![1];return Task.FromResult(new WritingScheduleDashboardViewModel{TodayTasks=[new(){BookID=2,SceneID=20},new(){BookID=3,SceneID=30}]});});
|
||||
var books=Proxy<IBookRepository>((method,args)=>method switch{"ListByProjectAsync"=>Task.FromResult<IReadOnlyList<Book>>([new(){BookID=2,ProjectID=1},new(){BookID=3,ProjectID=1}]),"GetAsync"=>Task.FromResult<Book?>(new(){BookID=(int)args![0]!,ProjectID=1}),_=>throw new Exception(method)});
|
||||
var access=Proxy<IProjectAccessService>((method,args)=>Task.FromResult(allowed));
|
||||
var controller=new WriterController(workspace,schedule,books,access);
|
||||
@ -20,6 +20,9 @@ internal static class WriterDashboardTests
|
||||
Check(model.BookID==3&&model.WriteNext.Single().SceneID==30&&model.WritingSchedule.TodayTasks.Single().SceneID==30,"book selection filters queues and tasks consistently");
|
||||
Check(scheduledBook==3&&model.Workspace=="Revision","book scope reaches schedule service before selection and active workspace persists");
|
||||
Check(await controller.Index(1,999) is NotFoundResult,"unknown book cannot fall back to another book");
|
||||
var setup = (ViewResult)await controller.ScheduleSetup(1, 3);
|
||||
Check(((WritingScheduleSetupViewModel)setup.Model!).BookID == 3, "plan setup retains selected book instead of All Books");
|
||||
Check(await controller.ScheduleSetup(99, 3) is NotFoundResult, "plan setup refuses conflicting project and book");
|
||||
allowed=false;Check(await controller.Index(null,3) is NotFoundResult,"book-only deep link checks access before metadata");
|
||||
Check(controller.LegacyWrite(1,3) is RedirectToActionResult redirect&&(int?)redirect.RouteValues!["bookId"]==3,"legacy Write redirect preserves book scope");
|
||||
var ribbon=ApplicationRibbon.Categories.Single(c=>c.Key=="writer");Check(ribbon.Groups.SelectMany(g=>g.Commands).Any(c=>c.Action=="Workspaces")&&ribbon.Groups.SelectMany(g=>g.Commands).Any(c=>c.Controller=="WritingActivity"),"Writer contextual commands target implemented workspaces and evidence");
|
||||
|
||||
@ -12,7 +12,7 @@ namespace PlotLine.Controllers;
|
||||
public sealed class WriterController(
|
||||
IWriterWorkspaceService writerWorkspace,
|
||||
IWritingScheduleService writingSchedule,
|
||||
IBookRepository? bookRepository=null, IProjectAccessService? access=null, WritingActivityRepository? activity=null) : Controller
|
||||
IBookRepository? bookRepository=null, IProjectAccessService? access=null, WritingActivityRepository? activity=null, WriterObjectiveRepository? objectives=null) : Controller
|
||||
{
|
||||
public async Task<IActionResult> Index(int? projectId,int? bookId=null,string? workspace=null,bool journey=false)
|
||||
{
|
||||
@ -43,6 +43,12 @@ public sealed class WriterController(
|
||||
{ try{model.Activity=await activity.Read(user,model.BookID.Value);}catch(SqlException e)when(e.Number==51000){ model.ActivityIsPrivate=true; } }
|
||||
if(activity!=null&&int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier),out var reader))model.StoryHealthReminders=await activity.Reminders(reader,model.BookID.Value);
|
||||
}
|
||||
if (objectives != null && model.BookID.HasValue && int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier), out var author))
|
||||
{
|
||||
var working = await objectives.Read(author, model.BookID.Value);
|
||||
model.Objective = working.Objective;
|
||||
model.ObjectiveChoices = working.Choices;
|
||||
}
|
||||
model.Workspace=workspace is "InProgress" or "Revision" or "FinalPass" or "StoryHealth"?workspace:"WriteNext";
|
||||
model.Journey=journey;
|
||||
model.WritingSchedule = await writingSchedule.GetTodayDashboardAsync(projectId,model.BookID);
|
||||
@ -56,6 +62,18 @@ public sealed class WriterController(
|
||||
[HttpGet("Write"),HttpGet("Write/Index")]
|
||||
public IActionResult LegacyWrite(int? projectId,int? bookId)=>RedirectToAction(nameof(Index),new{projectId,bookId});
|
||||
|
||||
[HttpPost, ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> SaveObjective(PlotLine.Models.WriterObjective model, bool scheduleNow = false)
|
||||
{
|
||||
if (access == null || !await access.CanAccessEntityAsync("Book", model.BookID)) return NotFound();
|
||||
if (!ModelState.IsValid || objectives == null || !int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier), out var author))
|
||||
{ TempData["WriterWorkspaceError"] = "Choose a working activity and a place in this book."; return RedirectToAction(nameof(Index), new { bookId = model.BookID, setup = true }); }
|
||||
try { await objectives.Save(author, model); }
|
||||
catch (SqlException e) when (e.Number == 51000)
|
||||
{ TempData["WriterWorkspaceError"] = "That chapter or scene is no longer available. Choose a place in this book."; return RedirectToAction(nameof(Index), new { bookId = model.BookID, setup = true }); }
|
||||
return scheduleNow ? RedirectToAction(nameof(ScheduleSetup), new { bookId = model.BookID }) : RedirectToAction(nameof(Index), new { bookId = model.BookID });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Chapter(int id)
|
||||
{
|
||||
var model = await writerWorkspace.GetChapterWorkflowAsync(id);
|
||||
@ -68,9 +86,19 @@ public sealed class WriterController(
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> WritingPlans()
|
||||
public async Task<IActionResult> WritingPlans(int? projectId = null, int? bookId = null)
|
||||
{
|
||||
PlotLine.Models.Book? selected = null;
|
||||
if (bookId.HasValue && bookRepository != null)
|
||||
{
|
||||
if (access != null && !await access.CanAccessEntityAsync("Book", bookId.Value)) return NotFound();
|
||||
selected = await bookRepository.GetAsync(bookId.Value);
|
||||
if (selected == null || selected.IsArchived || (projectId.HasValue && projectId != selected.ProjectID)) return NotFound();
|
||||
projectId = selected.ProjectID;
|
||||
}
|
||||
var model = await writingSchedule.GetWritingPlansForManagementAsync();
|
||||
model.ProjectID = projectId; model.BookID = bookId; model.BookTitle = selected?.BookDisplayTitle;
|
||||
model.Plans = model.Plans.Where(p => (!projectId.HasValue || p.ProjectID == projectId) && (!bookId.HasValue || p.BookID == null || p.BookID == bookId)).ToArray();
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@ -112,7 +140,8 @@ public sealed class WriterController(
|
||||
{
|
||||
await writingSchedule.UpdateWritingPlanSettingsAsync(model);
|
||||
TempData["WritingPlansMessage"] = "Writing plan updated.";
|
||||
return RedirectToAction(nameof(WritingPlans));
|
||||
var saved = await writingSchedule.GetWritingPlanSettingsAsync(model.WritingPlanID);
|
||||
return RedirectToAction(nameof(WritingPlans), new { projectId = saved.ProjectID, bookId = saved.BookID });
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
@ -138,9 +167,18 @@ public sealed class WriterController(
|
||||
return View(nameof(SchedulePreview), model);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> ScheduleSetup(int? projectId)
|
||||
public async Task<IActionResult> ScheduleSetup(int? projectId, int? bookId = null)
|
||||
{
|
||||
if (bookId.HasValue && bookRepository != null)
|
||||
{
|
||||
if (access != null && !await access.CanAccessEntityAsync("Book", bookId.Value)) return NotFound();
|
||||
var book = await bookRepository.GetAsync(bookId.Value);
|
||||
if (book == null || book.IsArchived || (projectId.HasValue && projectId != book.ProjectID)) return NotFound();
|
||||
projectId = book.ProjectID;
|
||||
}
|
||||
var model = await writingSchedule.GetScheduleSetupAsync(projectId);
|
||||
model.BookID = bookId;
|
||||
await writingSchedule.PopulateScheduleSetupOptionsAsync(model);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@ -312,24 +350,24 @@ public sealed class WriterController(
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> MarkScheduleItemComplete(int writingScheduleItemId, int? projectId)
|
||||
public async Task<IActionResult> MarkScheduleItemComplete(int writingScheduleItemId, int? projectId, int? bookId = null)
|
||||
{
|
||||
var updated = await writingSchedule.MarkScheduleItemCompleteAsync(writingScheduleItemId);
|
||||
TempData[updated ? "WriterWorkspaceMessage" : "WriterWorkspaceError"] = updated
|
||||
? "Writing task marked complete."
|
||||
: "Only planned writing tasks can be marked complete.";
|
||||
return RedirectToAction(nameof(Index), new { projectId });
|
||||
return RedirectToAction(nameof(Index), new { projectId, bookId });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> SkipScheduleItem(int writingScheduleItemId, int? projectId)
|
||||
public async Task<IActionResult> SkipScheduleItem(int writingScheduleItemId, int? projectId, int? bookId = null)
|
||||
{
|
||||
var updated = await writingSchedule.SkipScheduleItemAsync(writingScheduleItemId);
|
||||
TempData[updated ? "WriterWorkspaceMessage" : "WriterWorkspaceError"] = updated
|
||||
? "Writing task skipped."
|
||||
: "Only planned writing tasks can be skipped.";
|
||||
return RedirectToAction(nameof(Index), new { projectId });
|
||||
return RedirectToAction(nameof(Index), new { projectId, bookId });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -347,6 +385,7 @@ public sealed class WriterController(
|
||||
try
|
||||
{
|
||||
var existing = await writingSchedule.GetWritingPlanSettingsAsync(model.WritingPlanID);
|
||||
model.ProjectID = existing.ProjectID; model.BookID = existing.BookID;
|
||||
model.ProjectName = existing.ProjectName;
|
||||
model.BookName = existing.BookName;
|
||||
model.GoalType = existing.GoalType;
|
||||
|
||||
18
PlotLine/Data/WriterObjectiveRepository.cs
Normal file
18
PlotLine/Data/WriterObjectiveRepository.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using PlotLine.Models;
|
||||
namespace PlotLine.Data;
|
||||
public sealed class WriterObjectiveRepository(ISqlConnectionFactory factory)
|
||||
{
|
||||
public async Task<(WriterObjective? Objective, IReadOnlyList<WriterObjectiveChoice> Choices)> Read(int user, int book)
|
||||
{
|
||||
using var db = factory.CreateConnection();
|
||||
using var rows = await db.QueryMultipleAsync("dbo.WriterObjective", new { UserID = user, BookID = book, Action = "read" }, commandType: CommandType.StoredProcedure);
|
||||
return (await rows.ReadSingleOrDefaultAsync<WriterObjective>(), (await rows.ReadAsync<WriterObjectiveChoice>()).ToArray());
|
||||
}
|
||||
public async Task Save(int user, WriterObjective value)
|
||||
{
|
||||
using var db = factory.CreateConnection();
|
||||
await db.ExecuteAsync("dbo.WriterObjective", new { UserID = user, value.BookID, value.ChapterID, value.SceneID, value.Activity, Action = "save" }, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
20
PlotLine/Models/WriterObjective.cs
Normal file
20
PlotLine/Models/WriterObjective.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace PlotLine.Models;
|
||||
|
||||
public sealed class WriterObjective
|
||||
{
|
||||
public int BookID { get; set; }
|
||||
public int? ChapterID { get; set; }
|
||||
public int? SceneID { get; set; }
|
||||
[Required, RegularExpression("^(Drafting|Revising|Editing|Researching|Proofreading)$")]
|
||||
public string Activity { get; set; } = "Drafting";
|
||||
public string? ChapterTitle { get; set; }
|
||||
public string? SceneTitle { get; set; }
|
||||
}
|
||||
public sealed class WriterObjectiveChoice
|
||||
{
|
||||
public int ChapterID { get; set; }
|
||||
public string ChapterTitle { get; set; } = "";
|
||||
public int? SceneID { get; set; }
|
||||
public string? SceneTitle { get; set; }
|
||||
}
|
||||
@ -199,6 +199,7 @@ public class Program
|
||||
builder.Services.AddScoped<IImportRepository, ImportRepository>();
|
||||
builder.Services.AddScoped<IWordCompanionRepository, WordCompanionRepository>();
|
||||
builder.Services.AddScoped<WritingActivityRepository>();
|
||||
builder.Services.AddScoped<WriterObjectiveRepository>();
|
||||
builder.Services.AddHostedService<PlotLine.Services.WritingActivity.WritingActivityRetention>();
|
||||
builder.Services.AddScoped<IOnboardingRepository, OnboardingRepository>();
|
||||
builder.Services.AddScoped<IOnboardingBuildRepository, OnboardingBuildRepository>();
|
||||
|
||||
@ -28,8 +28,9 @@ public sealed class ApplicationNavigation(IProjectRepository projects, IBookRepo
|
||||
|
||||
var project = Project ?? Property(model, "Project") as Project ?? model as Project;
|
||||
var book = Property(model, "Book") as Book ?? (model as StoryPointViewModel)?.Snapshot?.Book;
|
||||
var writingPlan = (model as WritingSchedulePreviewViewModel)?.SelectedPlan;
|
||||
var projectId = project?.ProjectID ?? PositiveId(Property(model, "ProjectID"))
|
||||
?? book?.ProjectID ?? PositiveId(request.Query["projectId"].FirstOrDefault());
|
||||
?? book?.ProjectID ?? writingPlan?.ProjectID ?? PositiveId(request.Query["projectId"].FirstOrDefault());
|
||||
if (projectId is not > 0) return result;
|
||||
|
||||
// Resolve through the user-scoped repository even on models that only carry IDs.
|
||||
@ -43,7 +44,7 @@ public sealed class ApplicationNavigation(IProjectRepository projects, IBookRepo
|
||||
TimelineViewModel timeline => timeline.SelectedBookID,
|
||||
StoryCalendarViewModel calendar => calendar.SelectedBookID,
|
||||
NamesLibraryViewModel names => names.Filter.BookID,
|
||||
_ => book?.BookID ?? PositiveId(Property(model, "SelectedBookID"))
|
||||
_ => book?.BookID ?? writingPlan?.BookID ?? PositiveId(Property(model, "SelectedBookID"))
|
||||
?? PositiveId(Property(model, "BookID"))
|
||||
?? PositiveId(Property(Property(model, "Filter"), "BookID"))
|
||||
?? PositiveId(request.Query["bookId"].FirstOrDefault())
|
||||
|
||||
@ -33,7 +33,7 @@ public static class ApplicationRibbon
|
||||
new("Selected book", new("Book overview", "bible", "Books", "Details", "book"), new("Edit book", "writer", "Books", "Edit", "book"), new("Add chapter", "threads", "Chapters", "Create", "chapter")),
|
||||
new("Manuscript review", S("review")), new("Library", S("overview"), new("Add book", "bible", "Books", "Create"))),
|
||||
new("writer", "Writer",
|
||||
new("Writing", new("Overview","writer","Writer","Index","writerBook"),new("Writing Journey","calendar","Writer","Journey","writerBook"),new("Writing Plan","calendar","Writer","WritingPlans")),
|
||||
new("Writing", new("Overview","writer","Writer","Index","writerBook"),new("Writing Journey","calendar","Writer","Journey","writerBook"),new("Writing Plan","calendar","Writer","WritingPlans","writerBook")),
|
||||
new("Work",new("Workspaces","threads","Writer","Workspaces","writerBook"),new("Reports","metrics","WritingActivity","Index","writerBook",OwnerOnly:true)),
|
||||
new("Workspace setup",new RibbonCommand("Display Setup","maps","Writer","DisplaySetup","writerBook"))),
|
||||
new("story", "Story", new("Story structure", S("timeline"), S("plotlines"), S("threads"), S("calendar"), S("point")), new("Analysis & planning", S("review"), S("scenarios"), S("continuity"))),
|
||||
|
||||
@ -6475,6 +6475,7 @@ public sealed class WritingScheduleService(
|
||||
var model = new WritingPlanSettingsEditViewModel
|
||||
{
|
||||
WritingPlanID = plan.WritingPlanID,
|
||||
ProjectID = plan.ProjectID, BookID = plan.BookID,
|
||||
PlanName = plan.PlanName,
|
||||
ProjectName = project?.ProjectName ?? string.Empty,
|
||||
BookName = book?.BookDisplayTitle ?? "All Books",
|
||||
|
||||
49
PlotLine/Sql/261_WriterWorkingObjective.sql
Normal file
49
PlotLine/Sql/261_WriterWorkingObjective.sql
Normal file
@ -0,0 +1,49 @@
|
||||
SET ANSI_NULLS ON;
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
IF OBJECT_ID(N'dbo.WriterWorkingObjectives',N'U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE dbo.WriterWorkingObjectives
|
||||
(
|
||||
BookID int NOT NULL REFERENCES dbo.Books(BookID) ON DELETE CASCADE,
|
||||
UserID int NOT NULL REFERENCES dbo.AppUser(UserID) ON DELETE CASCADE,
|
||||
ChapterID int NULL,
|
||||
SceneID int NULL,
|
||||
Activity nvarchar(20) NOT NULL CHECK(Activity IN(N'Drafting',N'Revising',N'Editing',N'Researching',N'Proofreading')),
|
||||
UpdatedUtc datetime2 NOT NULL DEFAULT SYSUTCDATETIME(),
|
||||
CONSTRAINT PK_WriterWorkingObjectives PRIMARY KEY(BookID,UserID)
|
||||
);
|
||||
END;
|
||||
GO
|
||||
CREATE OR ALTER PROCEDURE dbo.WriterObjective
|
||||
@UserID int, @BookID int, @Action varchar(10)='read', @ChapterID int=NULL, @SceneID int=NULL, @Activity nvarchar(20)=NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
IF NOT EXISTS(SELECT 1 FROM dbo.Books b JOIN dbo.ProjectUserAccess a ON a.ProjectID=b.ProjectID
|
||||
WHERE b.BookID=@BookID AND b.IsArchived=0 AND a.UserID=@UserID AND a.IsActive=1)
|
||||
THROW 51000,'Book access denied',1;
|
||||
IF @Action='read'
|
||||
BEGIN
|
||||
SELECT o.BookID,o.Activity,o.ChapterID,o.SceneID,c.ChapterTitle,s.SceneTitle
|
||||
FROM dbo.WriterWorkingObjectives o
|
||||
LEFT JOIN dbo.Chapters c ON c.ChapterID=o.ChapterID AND c.BookID=@BookID AND c.IsArchived=0
|
||||
LEFT JOIN dbo.Scenes s ON s.SceneID=o.SceneID AND s.ChapterID=c.ChapterID AND s.IsArchived=0
|
||||
WHERE o.BookID=@BookID AND o.UserID=@UserID AND (o.ChapterID IS NULL OR c.ChapterID IS NOT NULL) AND (o.SceneID IS NULL OR s.SceneID IS NOT NULL);
|
||||
SELECT c.ChapterID,c.ChapterTitle,s.SceneID,s.SceneTitle FROM dbo.Chapters c
|
||||
LEFT JOIN dbo.Scenes s ON s.ChapterID=c.ChapterID AND s.IsArchived=0
|
||||
WHERE c.BookID=@BookID AND c.IsArchived=0 ORDER BY c.SortOrder,c.ChapterID,s.SortOrder,s.SceneID;
|
||||
RETURN;
|
||||
END;
|
||||
IF @Action<>'save' THROW 51000,'Unknown objective action',1;
|
||||
IF @Activity IS NULL OR @Activity NOT IN(N'Drafting',N'Revising',N'Editing',N'Researching',N'Proofreading') THROW 51000,'Choose a working activity',1;
|
||||
IF @ChapterID IS NOT NULL AND NOT EXISTS(SELECT 1 FROM dbo.Chapters WHERE ChapterID=@ChapterID AND BookID=@BookID AND IsArchived=0) THROW 51000,'Chapter is unavailable in this book',1;
|
||||
IF @SceneID IS NOT NULL AND NOT EXISTS(SELECT 1 FROM dbo.Scenes WHERE SceneID=@SceneID AND ChapterID=@ChapterID AND IsArchived=0) THROW 51000,'Scene is unavailable in this chapter',1;
|
||||
SET XACT_ABORT ON;
|
||||
BEGIN TRANSACTION;
|
||||
IF EXISTS(SELECT 1 FROM dbo.WriterWorkingObjectives WITH(UPDLOCK,HOLDLOCK) WHERE BookID=@BookID AND UserID=@UserID)
|
||||
UPDATE dbo.WriterWorkingObjectives SET ChapterID=@ChapterID,SceneID=@SceneID,Activity=@Activity,UpdatedUtc=SYSUTCDATETIME() WHERE BookID=@BookID AND UserID=@UserID;
|
||||
ELSE INSERT dbo.WriterWorkingObjectives(BookID,UserID,ChapterID,SceneID,Activity) VALUES(@BookID,@UserID,@ChapterID,@SceneID,@Activity);
|
||||
COMMIT;
|
||||
END;
|
||||
GO
|
||||
@ -925,6 +925,8 @@ public sealed class ChapterWorkflowViewModel
|
||||
|
||||
public sealed class WriterDashboardViewModel
|
||||
{
|
||||
public WriterObjective? Objective { get; set; }
|
||||
public IReadOnlyList<WriterObjectiveChoice> ObjectiveChoices { get; set; } = [];
|
||||
public int? BookID { get; set; }
|
||||
public Book? Book { get; set; }
|
||||
public PlotLine.Models.WritingActivityPage? Activity { get; set; }
|
||||
@ -978,6 +980,9 @@ public sealed class WritingPlanViewModel
|
||||
|
||||
public sealed class WritingPlansManagementViewModel
|
||||
{
|
||||
public int? ProjectID { get; set; }
|
||||
public int? BookID { get; set; }
|
||||
public string? BookTitle { get; set; }
|
||||
public IReadOnlyList<WritingPlanManagementItem> Plans { get; set; } = [];
|
||||
}
|
||||
|
||||
@ -990,6 +995,8 @@ public sealed class WritingDayAvailabilityViewModel
|
||||
|
||||
public sealed class WritingPlanSettingsEditViewModel
|
||||
{
|
||||
public int ProjectID { get; set; }
|
||||
public int? BookID { get; set; }
|
||||
public int WritingPlanID { get; set; }
|
||||
|
||||
[Required, StringLength(200)]
|
||||
|
||||
@ -177,7 +177,7 @@
|
||||
</section>
|
||||
|
||||
<section class="list-section">
|
||||
<h2>Chapters <help-icon key="books.chapters" /></h2>
|
||||
<h2 id="chapters">Chapters <help-icon key="books.chapters" /></h2>
|
||||
<a class="btn btn-outline-secondary" asp-controller="ManuscriptReader" asp-action="Index" asp-route-bookId="@Model.Book.BookID">Read manuscript</a>
|
||||
@if (!Model.Chapters.Any())
|
||||
{
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
}
|
||||
|
||||
<nav data-pwa-identity class="breadcrumb-trail" aria-label="Breadcrumb">
|
||||
<a asp-controller="Writer" asp-action="Index">Writer Workspace</a>
|
||||
<a asp-controller="Writer" asp-action="WritingPlans">Writing Plans</a>
|
||||
<a asp-controller="Writer" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Writer</a>
|
||||
<a asp-controller="Writer" asp-action="WritingPlans" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Writing Plans</a>
|
||||
<span>Edit Plan</span>
|
||||
</nav>
|
||||
|
||||
@ -112,7 +112,7 @@
|
||||
|
||||
<div data-pwa-context="Record" data-pwa-priority="0" class="button-row mt-3">
|
||||
<button class="btn btn-primary" data-pwa-icon="save" type="submit">Save Plan</button>
|
||||
<a class="btn btn-outline-secondary" data-pwa-icon="close" asp-action="WritingPlans">Cancel</a>
|
||||
<a class="btn btn-outline-secondary" data-pwa-icon="close" asp-action="WritingPlans" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
@ -6,9 +6,10 @@
|
||||
var seed=Model.WriteNext.Concat(Model.ContinueWriting).Concat(Model.RevisionQueue).Concat(Model.PolishingQueue).FirstOrDefault();
|
||||
var bookId=Model.BookID??seed?.BookID;
|
||||
var bookTitle=Model.Book?.BookDisplayTitle??seed?.BookDisplayTitle??"Choose a book";
|
||||
var next=Model.ContinueWriting.FirstOrDefault()??Model.WriteNext.FirstOrDefault()??Model.RevisionQueue.FirstOrDefault()??Model.PolishingQueue.FirstOrDefault();
|
||||
if(string.IsNullOrWhiteSpace(bookTitle)) bookTitle = Model.BookID.HasValue ? "Untitled book" : "Choose a book";
|
||||
var opportunity=Model.WritingSchedule.TodayTasks.FirstOrDefault()??Model.WritingSchedule.UpcomingTasks.FirstOrDefault();
|
||||
var totals=Model.Activity?.Totals.HasAcceptedEvidence==true?Model.Activity.Totals:null;
|
||||
var showWorkspace = Context.Request.RouteValues["action"]?.ToString() == "Workspaces";
|
||||
var queues=new[]{("WriteNext","Write Next",Model.WriteNext),("InProgress","In Progress",Model.ContinueWriting),("Revision","Revision",Model.RevisionQueue),("FinalPass","Final Pass",Model.PolishingQueue)};
|
||||
var days=Model.Activity?.Days??Array.Empty<PlotLine.Models.WritingActivityDay>();
|
||||
var maximum=Math.Max(1L,days.Select(x=>x.Added+x.Removed).DefaultIfEmpty(1).Max());
|
||||
@ -16,63 +17,69 @@
|
||||
<link rel="stylesheet" href="~/css/writer-dashboard.css" asp-append-version="true" />
|
||||
<div class="writer-studio" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@bookId">
|
||||
<header class="writer-heading" data-pwa-task>
|
||||
@if(!string.IsNullOrWhiteSpace(Model.Book?.CoverThumbnailPath)){<img class="writer-book-cover" src="@Url.Content(Model.Book.CoverThumbnailPath)" alt="Cover of @bookTitle" />}else{<div class="writer-book-cover writer-cover-fallback" aria-hidden="true">@(bookTitle[..1])</div>}
|
||||
<div><p class="eyebrow">@(Model.Journey?"Writing Journey":"Your writing desk")</p><h1>@bookTitle</h1><p class="muted">@(Model.Journey?"Accepted activity and the work ahead.":"Continue your manuscript, review your work, or choose what comes next.")</p></div>
|
||||
<div class="writer-connection"><span class="writer-status-dot" aria-hidden="true"></span>Word Companion <strong data-writing-workspace-word aria-live="polite">Checking…</strong><a href="#display-setup">Connection & Display Setup</a></div>
|
||||
<div class="writer-connection"><span class="writer-status-dot" aria-hidden="true"></span>Companion <strong data-writing-workspace-word aria-live="polite">Checking…</strong><a href="#display-setup">Connection & Display Setup</a></div>
|
||||
</header>
|
||||
@if(TempData["WriterWorkspaceMessage"] is string message){<p class="alert alert-info" role="status">@message</p>}
|
||||
@if(TempData["WriterWorkspaceError"] is string error){<p class="alert alert-warning" role="alert">@error</p>}
|
||||
@if(!Model.Journey)
|
||||
{
|
||||
<section class="writer-next-grid" aria-label="Current work and next opportunity">
|
||||
<article class="writer-card writer-current"><p class="eyebrow">Continue writing</p>
|
||||
@if(next!=null){<h2><a asp-controller="Scenes" asp-action="Edit" asp-route-id="@next.SceneID">@next.SceneTitle</a></h2><p><a asp-action="Chapter" asp-route-id="@next.ChapterID">Chapter @next.ChapterNumber</a> · @next.RevisionStatusName</p><p class="writer-excerpt">@next.Summary</p><div class="button-row"><a class="btn btn-primary" asp-controller="Scenes" asp-action="Edit" asp-route-id="@next.SceneID">Continue scene</a><a class="btn btn-outline-secondary" asp-controller="ManuscriptReader" asp-action="Index" asp-route-bookId="@bookId" asp-route-chapterId="@next.ChapterID">Read manuscript</a></div>}
|
||||
else{<h2>Your manuscript, at your pace</h2><p>Choose a book in the application bar to find its chapters and writing work.</p>@if(bookId.HasValue){<a class="btn btn-primary" asp-controller="Chapters" asp-action="Index" asp-route-bookId="@bookId">Open chapters</a>}}
|
||||
</article>
|
||||
<article class="writer-card"><p class="eyebrow">Next writing opportunity · Planned</p>
|
||||
<partial name="_WorkingObjective" model="Model" />
|
||||
<article class="writer-card"><p class="eyebrow">Next Planned Session</p>
|
||||
@if(opportunity!=null){<h2>@opportunity.ScheduledDate.ToString("ddd d MMM")</h2><p>@opportunity.TaskType · @opportunity.EstimatedMinutes estimated minutes</p><a asp-controller="Scenes" asp-action="Edit" asp-route-id="@opportunity.SceneID">@opportunity.SceneTitle</a><p class="muted">Planned capacity, not measured writing time.</p>}
|
||||
else{<h2>Make room for your next page</h2><p>No upcoming writing task is scheduled for this book.</p><a class="btn btn-outline-primary" asp-action="ScheduleSetup" asp-route-projectId="@Model.ProjectID">Create a writing plan</a>}
|
||||
<a class="writer-text-link" asp-action="WritingPlans">Manage writing plans</a>
|
||||
else{<h2>Plan your writing time</h2><p>No upcoming writing task is scheduled for this book.</p><a class="btn btn-outline-primary" asp-action="ScheduleSetup" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@bookId">Create a writing plan</a>}
|
||||
<a class="writer-text-link" asp-action="WritingPlans" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@bookId">Manage writing plans</a>
|
||||
</article>
|
||||
</section>
|
||||
@if(!Model.ActivityIsPrivate)
|
||||
{
|
||||
<section class="writer-indicators" aria-label="Recorded progress in the last 30 days">
|
||||
<a class="writer-card" asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId"><span class="eyebrow">Observed additions</span><strong>@(totals==null?"—":totals.Added.ToString("N0"))</strong><span>Words between accepted snapshots</span></a>
|
||||
<a class="writer-card" asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId"><span class="eyebrow">Observed deletions</span><strong>@(totals==null?"—":totals.Removed.ToString("N0"))</strong><span>Revision can include removing words</span></a>
|
||||
<a class="writer-card" asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId"><span class="eyebrow">Net manuscript change</span><strong>@(totals==null?"—":totals.Net.ToString("+0;-0;0"))</strong><span>Last 30 days · receipt dates (UTC)</span></a>
|
||||
<a class="writer-card" asp-action="Workspaces" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@bookId" asp-route-workspace="Revision"><span class="eyebrow">Revision workspace</span><strong>@Model.RevisionQueue.Count</strong><span>Scenes marked Needs Work · workflow status</span></a>
|
||||
<section class="writer-card writer-progress" aria-label="Writing Progress">
|
||||
<div><p class="eyebrow">Writing Progress · last 30 days</p><h2>Your Manuscript</h2>
|
||||
<p>@(Model.Book?.CurrentWordCount.ToString("N0") ?? "—") words · @(Model.Book?.ChapterCount ?? 0) chapters · @(Model.Book?.SceneCount ?? 0) scenes</p>@if(bookId.HasValue){<a asp-controller="Books" asp-action="Details" asp-route-id="@bookId" asp-fragment="chapters">Open Chapters</a>}</div>
|
||||
@if(totals != null && (totals.Added > 0 || totals.Removed > 0))
|
||||
{
|
||||
<div class="writer-activity-graphic"><div class="writer-change-track"><span class="writer-change-added" style="flex:@totals.Added"></span><span class="writer-change-removed" style="flex:@totals.Removed"></span></div><p><strong>+@totals.Added.ToString("N0")</strong> added · <strong>−@totals.Removed.ToString("N0")</strong> removed · <strong>@totals.Net.ToString("+0;-0;0")</strong> net</p></div>
|
||||
}
|
||||
else{<p class="writer-empty">@(totals?.HasAcceptedEvidence == true ? "Tracking begins at your manuscript baseline. New accepted changes will appear here." : "Activity begins with your first accepted manuscript baseline. Earlier writing cannot be reconstructed.")</p>}
|
||||
<div class="writer-workflow-progress" aria-label="Scenes in writing workspace queues">@foreach(var q in queues.Where(x=>x.Item3.Count>0)){<span class="writer-stage-@q.Item1" style="flex:@q.Item3.Count" title="@q.Item2: @q.Item3.Count scenes"></span>}</div>
|
||||
<div class="writer-workflow-strip" aria-label="Scene workflow stages">@foreach(var q in queues){<a asp-action="Workspaces" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@bookId" asp-route-workspace="@q.Item1"><strong>@q.Item3.Count</strong> @q.Item2</a>}</div>
|
||||
@if(bookId.HasValue){<a asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId">Reports & activity settings</a>}
|
||||
</section>
|
||||
}
|
||||
}
|
||||
<section class="writer-card writer-journey" aria-labelledby="writer-journey-title">
|
||||
<div class="writer-section-heading"><div><p class="eyebrow">Writing calendar · last 28 days</p><h2 id="writer-journey-title">The shape of your recent work</h2></div><a asp-action="Journey" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@bookId">Writing Journey</a></div>
|
||||
<section class="writer-card writer-journey @(Model.Journey ? "" : "writer-journey-compact")" aria-labelledby="writer-journey-title">
|
||||
<div class="writer-section-heading"><div><p class="eyebrow">@(Model.Journey ? "Writing calendar · last 28 days" : "Activity summary · last 28 days")</p><h2 id="writer-journey-title">Recent Activity</h2></div><a asp-action="Journey" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@bookId">Writing Journey</a></div>
|
||||
@if(totals==null||totals.RecordedEvents==0)
|
||||
{
|
||||
<p class="writer-empty">@(Model.Activity?.Totals.HasAcceptedEvidence==true?"No accepted change is recorded in this period. Retained baseline evidence is available in activity settings.":"Your accepted manuscript can become the starting point. Earlier writing will not be counted as new activity.")</p>
|
||||
@if(bookId.HasValue&&!Model.ActivityIsPrivate){<a class="btn btn-outline-primary" asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId">Activity & baseline settings</a>}
|
||||
<p class="writer-empty">@(!Model.Journey?"No new accepted changes yet.":Model.Activity?.Totals.HasAcceptedEvidence==true?"No accepted change is recorded in this period. Retained baseline evidence is available in activity settings.":"Your accepted manuscript can become the starting point. Earlier writing will not be counted as new activity.")</p>
|
||||
@if(Model.Journey&&bookId.HasValue&&!Model.ActivityIsPrivate){<a class="btn btn-outline-primary" asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId">Activity & baseline settings</a>}
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="writer-calendar" aria-label="Daily observed changes; receipt dates in UTC">
|
||||
@for(var i=27;i>=0;i--){var date=DateTime.UtcNow.Date.AddDays(-i);var day=days.FirstOrDefault(x=>x.Day.Date==date);<a class="writer-day @(day==null?"writer-day-unobserved":"writer-day-observed")" asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId" asp-route-day="@date.ToString("yyyy-MM-dd")" aria-label="@date.ToString("d MMM yyyy"): @(day==null?"no recorded change":$"{day.Changes} changes, {day.Added} added, {day.Removed} removed")"><span>@date.ToString("ddd")</span><strong>@date.Day</strong><small>@(day==null?"—":$"+{day.Added} / −{day.Removed}")</small></a>}
|
||||
@for(var i=27;i>=0;i--){var date=DateTime.UtcNow.Date.AddDays(-i);var day=days.FirstOrDefault(x=>x.Day.Date==date);<a class="writer-day @(day==null?"writer-day-unobserved":"writer-day-observed")" asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId" asp-route-day="@date.ToString("yyyy-MM-dd")" aria-label="@date.ToString("d MMM yyyy"): @(day==null?"no recorded change":$"{day.Changes} changes, {day.Added} added, {day.Removed} removed")">@if(Model.Journey){<span>@date.ToString("ddd")</span><strong>@date.Day</strong><small>@(day==null?"—":$"+{day.Added} / −{day.Removed}")</small>}</a>}
|
||||
</div>
|
||||
<p class="writer-coverage"><strong>@totals.ActiveDays observed change days in the last 30 days.</strong> Receipt dates use UTC; they do not establish when the author wrote each word. Grey means no recorded change, not a missed opportunity. @if(totals.PartialComparisons>0){<span>@totals.PartialComparisons comparisons contain qualified minimum estimates.</span>}</p>
|
||||
<details><summary>Manuscript changes by day</summary><div class="writer-change-chart" aria-label="Observed additions and deletions with numeric labels">@foreach(var day in days){<a class="writer-change-row" asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId" asp-route-day="@day.Day.ToString("yyyy-MM-dd")"><span>@day.Day.ToString("d MMM")</span><span class="writer-bar-track"><i class="writer-bar-added" style="width:@((100m*day.Added/maximum).ToString("0.##",System.Globalization.CultureInfo.InvariantCulture))%"></i><i class="writer-bar-removed" style="width:@((100m*day.Removed/maximum).ToString("0.##",System.Globalization.CultureInfo.InvariantCulture))%"></i></span><span>+@day.Added / −@day.Removed</span></a>}</div></details>
|
||||
<p class="writer-coverage" hidden="@(!Model.Journey)"><strong>@totals.ActiveDays observed change days in the last 30 days.</strong> Receipt dates use UTC; they do not establish when the author wrote each word. Grey means no recorded change, not a missed opportunity. @if(totals.PartialComparisons>0){<span>@totals.PartialComparisons comparisons contain qualified minimum estimates.</span>}</p>
|
||||
<details hidden="@(!Model.Journey)"><summary>Manuscript changes by day</summary><div class="writer-change-chart" aria-label="Observed additions and deletions with numeric labels">@foreach(var day in days){<a class="writer-change-row" asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId" asp-route-day="@day.Day.ToString("yyyy-MM-dd")"><span>@day.Day.ToString("d MMM")</span><span class="writer-bar-track"><i class="writer-bar-added" style="width:@((100m*day.Added/maximum).ToString("0.##",System.Globalization.CultureInfo.InvariantCulture))%"></i><i class="writer-bar-removed" style="width:@((100m*day.Removed/maximum).ToString("0.##",System.Globalization.CultureInfo.InvariantCulture))%"></i></span><span>+@day.Added / −@day.Removed</span></a>}</div></details>
|
||||
}
|
||||
@if(Model.ActivityIsPrivate){<p class="muted">Activity evidence is private to the book owner. Your existing writing workspaces remain available.</p>}
|
||||
@if(Model.Activity?.Events.Count>0)
|
||||
@if(Model.Journey&&Model.Activity?.Events.Count>0)
|
||||
{
|
||||
<details class="mt-3"><summary>Recent activity · source evidence</summary><ul class="writer-recent">@foreach(var e in Model.Activity.Events.Take(5)){<li><a asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@bookId" asp-route-day="@e.ReceivedUtc.ToString("yyyy-MM-dd")">@e.ReceivedUtc.ToString("d MMM HH:mm") UTC · @e.Kind</a><span>@e.Source · @(e.Kind=="Change"?$"+{e.Added} / −{e.Removed}":e.Coverage)</span></li>}</ul></details>
|
||||
}
|
||||
@if(Model.Journey&&Model.WritingSchedule.UpcomingTasks.Count>0){<h3 class="mt-3">Planned work ahead</h3><ul>@foreach(var item in Model.WritingSchedule.UpcomingTasks){<li>@item.ScheduledDate.ToString("ddd d MMM") · <a asp-controller="Scenes" asp-action="Edit" asp-route-id="@item.SceneID">@item.SceneTitle</a> · @item.TaskType</li>}</ul>}
|
||||
</section>
|
||||
<section class="writer-card writer-workspaces" id="workspaces" aria-labelledby="writer-workspace-title">
|
||||
<div class="writer-section-heading"><div><p class="eyebrow">Workspaces</p><h2 id="writer-workspace-title">Choose your next step</h2></div><a asp-controller="Chapters" asp-action="Index" asp-route-bookId="@bookId">Browse chapters</a></div>
|
||||
<div class="writer-section-heading"><div><p class="eyebrow">Workspaces</p><h2 id="writer-workspace-title">Choose your next step</h2></div>@if(bookId.HasValue){<a asp-controller="Books" asp-action="Details" asp-route-id="@bookId" asp-fragment="chapters">Browse chapters</a>}</div>
|
||||
<details class="writer-queue-details" open="@showWorkspace"><summary>Chapter and scene workspaces</summary>
|
||||
<nav class="writer-tabs" aria-label="Writing workspaces">@foreach(var q in queues){<a asp-action="Workspaces" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@bookId" asp-route-workspace="@q.Item1" aria-current="@(Model.Workspace==q.Item1?"page":null)">@q.Item2 <span>@q.Item3.Count</span></a>}<a asp-action="Workspaces" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@bookId" asp-route-workspace="StoryHealth" aria-current="@(Model.Workspace=="StoryHealth"?"page":null)">Story Health <span>@Model.StoryHealthReminders.Count</span></a></nav>
|
||||
@foreach(var q in queues){<div data-writer-queue="@q.Item1" hidden="@(Model.Workspace!=q.Item1)"><partial name="_WriterSceneQueue" model="q.Item3" /></div>}
|
||||
<div hidden="@(Model.Workspace!="StoryHealth")">@if(Model.StoryHealthReminders.Count==0){<p class="muted">No current book reminders are listed. You can also review project story health.</p>}@foreach(var reminder in Model.StoryHealthReminders){<article class="writer-reminder"><span class="status-pill">@reminder.Category</span>@if(reminder.SceneID.HasValue){<a asp-controller="Scenes" asp-action="Edit" asp-route-id="@reminder.SceneID">@reminder.Title</a>}else if(reminder.EntityType=="Chapter"){<a asp-action="Chapter" asp-route-id="@reminder.EntityID">@reminder.Title</a>}else{<strong>@reminder.Title</strong>}<p>@reminder.Detail</p></article>}<a asp-controller="Analytics" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@bookId">Project story health</a></div>
|
||||
</details>
|
||||
</section>
|
||||
@if(Model.WritingSchedule.TodayTasks.Count>0){<details class="writer-card"><summary>Today's planned writing · @Model.WritingSchedule.TodayTasks.Count tasks</summary>@foreach(var task in Model.WritingSchedule.TodayTasks){<article class="writer-planned-task"><a asp-controller="Scenes" asp-action="Edit" asp-route-id="@task.SceneID">@task.SceneTitle</a><span>@task.TaskType · @task.EstimatedMinutes estimated minutes</span><form asp-action="MarkScheduleItemComplete" method="post"><input type="hidden" name="writingScheduleItemId" value="@task.WritingScheduleItemID" /><input type="hidden" name="projectId" value="@Model.ProjectID" /><button class="btn btn-sm btn-outline-primary">Mark complete</button></form><form asp-action="SkipScheduleItem" method="post"><input type="hidden" name="writingScheduleItemId" value="@task.WritingScheduleItemID" /><input type="hidden" name="projectId" value="@Model.ProjectID" /><button class="btn btn-sm btn-outline-secondary">Skip</button></form></article>}<p class="muted">Task completion is author-declared, not measured writing time.</p></details>}
|
||||
@if(Model.WritingSchedule.TodayTasks.Count>0){<details class="writer-card"><summary>Today's planned writing · @Model.WritingSchedule.TodayTasks.Count tasks</summary>@foreach(var task in Model.WritingSchedule.TodayTasks){<article class="writer-planned-task"><a asp-controller="Scenes" asp-action="Edit" asp-route-id="@task.SceneID">@task.SceneTitle</a><span>@task.TaskType · @task.EstimatedMinutes estimated minutes</span><form asp-action="MarkScheduleItemComplete" method="post"><input type="hidden" name="writingScheduleItemId" value="@task.WritingScheduleItemID" /><input type="hidden" name="projectId" value="@Model.ProjectID" /><input type="hidden" name="bookId" value="@bookId" /><button class="btn btn-sm btn-outline-primary">Mark complete</button></form><form asp-action="SkipScheduleItem" method="post"><input type="hidden" name="writingScheduleItemId" value="@task.WritingScheduleItemID" /><input type="hidden" name="projectId" value="@Model.ProjectID" /><input type="hidden" name="bookId" value="@bookId" /><button class="btn btn-sm btn-outline-secondary">Skip</button></form></article>}<p class="muted">Task completion is author-declared, not measured writing time.</p></details>}
|
||||
<details class="writer-card writer-display-setup" id="display-setup"><summary>Word Companion & Display Setup</summary>
|
||||
<p class="muted">Open Context and Intent as reference windows. Linked Word controls appear when a document is connected. Display placement depends on browser permission and popup support; moving Word itself is controlled by Windows.</p>
|
||||
<div class="writing-workspace-status-grid"><div>Selected book <strong data-writing-workspace-book>Waiting for Word</strong></div><div>Context <strong data-writing-workspace-context>Checking…</strong></div><div>Intent <strong data-writing-workspace-intent>Checking…</strong></div><div>Layout <strong data-writing-workspace-layout>Adaptive</strong></div></div>
|
||||
@ -84,5 +91,6 @@ else
|
||||
@section Scripts {
|
||||
<script src="~/js/writing-workspace.js" asp-append-version="true"></script>
|
||||
<script src="~/js/writing-workspace-launcher.js" asp-append-version="true"></script>
|
||||
<script src="~/js/writer-objective.js" asp-append-version="true"></script>
|
||||
<script>(()=>{const open=()=>{if(location.hash==='#display-setup')document.getElementById('display-setup').open=true;};window.addEventListener('hashchange',open);open();})();</script>
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
}
|
||||
|
||||
<nav data-pwa-identity class="breadcrumb-trail" aria-label="Breadcrumb">
|
||||
<a asp-controller="Writer" asp-action="Index">Writer Workspace</a>
|
||||
<a asp-controller="Writer" asp-action="WritingPlans">Writing Plans</a>
|
||||
<a asp-controller="Writer" asp-action="Index" asp-route-projectId="@Model.SelectedPlan?.ProjectID" asp-route-bookId="@Model.SelectedPlan?.BookID">Writer</a>
|
||||
<a asp-controller="Writer" asp-action="WritingPlans" asp-route-projectId="@Model.SelectedPlan?.ProjectID" asp-route-bookId="@Model.SelectedPlan?.BookID">Writing Plans</a>
|
||||
<span>Schedule Preview</span>
|
||||
</nav>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<p class="lead-text">Generated writing schedule items.</p>
|
||||
</div>
|
||||
<div class="button-row">
|
||||
<a class="btn btn-outline-secondary" asp-action="WritingPlans">Back to Writing Plans</a>
|
||||
<a class="btn btn-outline-secondary" asp-action="WritingPlans" asp-route-projectId="@Model.SelectedPlan?.ProjectID" asp-route-bookId="@Model.SelectedPlan?.BookID">Back to Writing Plans</a>
|
||||
@if (Model.SelectedPlan is not null)
|
||||
{
|
||||
<a class="btn btn-outline-primary" asp-action="EditWritingPlan" asp-route-writingPlanId="@Model.SelectedPlan.WritingPlanID">Edit Plan</a>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
}
|
||||
|
||||
<nav data-pwa-identity class="breadcrumb-trail" aria-label="Breadcrumb">
|
||||
<a asp-controller="Writer" asp-action="Index">Writer Workspace</a>
|
||||
<a asp-controller="Writer" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Writer</a>
|
||||
<span>Schedule Setup</span>
|
||||
</nav>
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<div>
|
||||
<p class="eyebrow">Writing schedule</p>
|
||||
<h1>Schedule Setup</h1>
|
||||
<p class="lead-text">Create a writing plan and generate its first schedule.</p>
|
||||
<p class="lead-text">Plan for the selected book, or choose All Books for a project-wide plan.</p><a asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Skip scheduling · return to Writer</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
}
|
||||
|
||||
<nav data-pwa-identity class="breadcrumb-trail" aria-label="Breadcrumb">
|
||||
<a asp-controller="Writer" asp-action="Index">Writer Workspace</a>
|
||||
<a asp-controller="Writer" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Writer</a>
|
||||
<span>Writing Plans</span>
|
||||
</nav>
|
||||
|
||||
@ -15,10 +15,10 @@
|
||||
<div>
|
||||
<p class="eyebrow">Schedule admin</p>
|
||||
<h1>Writing Plans</h1>
|
||||
<p class="lead-text">Manage writing plans and their generated schedules.</p>
|
||||
<p class="lead-text">@(Model.BookID.HasValue ? $"Plans for {Model.BookTitle}, including project-wide All Books plans." : "Manage writing plans and their generated schedules.")</p><a asp-action="WritingPlans">View plans across all projects and books</a>
|
||||
</div>
|
||||
<div class="button-row">
|
||||
<a class="btn btn-primary" asp-action="ScheduleSetup">Create Writing Schedule</a>
|
||||
<a class="btn btn-primary" asp-action="ScheduleSetup" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Create Writing Schedule</a>
|
||||
<a class="btn btn-outline-secondary" asp-action="SchedulePreview">Schedule Preview</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
39
PlotLine/Views/Writer/_WorkingObjective.cshtml
Normal file
39
PlotLine/Views/Writer/_WorkingObjective.cshtml
Normal file
@ -0,0 +1,39 @@
|
||||
@model WriterDashboardViewModel
|
||||
@{ var objective = Model.Objective; var editing = Context.Request.Query["setup"] == "true"; }
|
||||
@if (objective != null && !editing)
|
||||
{
|
||||
<article class="writer-current writer-card">
|
||||
<p class="eyebrow">@objective.Activity</p><h2>Continue Writing</h2>
|
||||
<h3>@(objective.SceneTitle ?? objective.ChapterTitle ?? Model.Book?.BookDisplayTitle)</h3>
|
||||
@if(objective.SceneID.HasValue){<a class="btn btn-primary" asp-controller="Scenes" asp-action="Edit" asp-route-id="@objective.SceneID">Continue Writing</a>}
|
||||
else if(objective.ChapterID.HasValue){<a class="btn btn-primary" asp-action="Chapter" asp-route-id="@objective.ChapterID">Continue Writing</a>}
|
||||
else{<a class="btn btn-primary" asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID" asp-fragment="chapters">Continue Writing</a>}
|
||||
<a class="writer-text-link" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID" asp-route-setup="true" asp-fragment="working-objective">Change objective</a>
|
||||
</article>
|
||||
}
|
||||
else if(Model.BookID.HasValue)
|
||||
{
|
||||
<article class="writer-card writer-start" id="working-objective">
|
||||
<p class="eyebrow">@Model.Book?.BookDisplayTitle</p><h2>Start Here</h2>
|
||||
<p>Choose what you want to work on. You can start without a writing plan.</p>
|
||||
<div class="writer-start-paths">
|
||||
<a class="writer-path" href="#objective-setup" data-open-objective><strong>Continue an existing manuscript</strong><span>Choose a chapter or scene and your working activity.</span></a>
|
||||
<a class="writer-path" asp-action="ScheduleSetup" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID"><strong>Plan your writing time</strong><span>Set availability, goals and a deadline.</span></a>
|
||||
<a class="writer-path" asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID" asp-fragment="chapters"><strong>Explore your manuscript</strong><span>@Model.Book?.ChapterCount chapters · @Model.Book?.SceneCount scenes</span></a>
|
||||
</div>
|
||||
<details id="objective-setup" open="@editing">
|
||||
<summary>Choose your working objective</summary>
|
||||
<form asp-action="SaveObjective" method="post" class="writer-objective-form">
|
||||
<input type="hidden" name="BookID" value="@Model.BookID" />
|
||||
<label>Working activity<select class="form-select" name="Activity">@foreach(var activity in new[]{"Drafting","Revising","Editing","Researching","Proofreading"}){<option selected="@(objective?.Activity==activity)" value="@activity">@activity</option>}</select></label>
|
||||
<label>Begin with<select class="form-select" name="ChapterID" data-objective-chapter><option value="">Whole manuscript</option>@foreach(var chapter in Model.ObjectiveChoices.DistinctBy(x=>x.ChapterID)){<option value="@chapter.ChapterID" selected="@(objective?.ChapterID==chapter.ChapterID)">@chapter.ChapterTitle</option>}</select></label>
|
||||
<label>Scene (optional)<select class="form-select" name="SceneID" data-objective-scene><option value="">Chapter workspace</option>@foreach(var scene in Model.ObjectiveChoices.Where(x=>x.SceneID.HasValue)){<option value="@scene.SceneID" data-chapter="@scene.ChapterID" selected="@(objective?.SceneID==scene.SceneID)">@scene.SceneTitle</option>}</select></label>
|
||||
<div class="button-row"><button class="btn btn-primary" name="scheduleNow" value="false">Save objective · start without a schedule</button><button class="btn btn-outline-secondary" name="scheduleNow" value="true">Save & plan writing time</button></div>
|
||||
</form>
|
||||
</details>
|
||||
</article>
|
||||
}
|
||||
else
|
||||
{
|
||||
<article class="writer-card"><h2>Start Here</h2><p>Select a project and book in the application bar to begin.</p><a class="btn btn-primary" asp-controller="Projects" asp-action="Index">Your projects</a></article>
|
||||
}
|
||||
@ -5,3 +5,8 @@
|
||||
@media(max-width:1050px){.writer-indicators{grid-template-columns:repeat(2,minmax(0,1fr))}.writer-calendar{grid-template-columns:repeat(7,minmax(0,1fr))}}
|
||||
@media(max-width:650px){.writer-heading{display:block}.writer-connection{margin-top:1rem}.writer-next-grid{grid-template-columns:1fr}.writer-card{padding:1rem}.writer-section-heading{align-items:flex-start;gap:.7rem}.writer-section-heading>a{font-size:.8rem}.writer-calendar{gap:.25rem}.writer-indicators{gap:.6rem}.writer-indicators strong{font-size:1.8rem}.writer-indicators .eyebrow{font-size:.6rem}.writer-change-row{grid-template-columns:50px 1fr 85px;font-size:.7rem}.writer-display-setup .writing-workspace-display-controls{display:flex;flex-direction:column;align-items:stretch}}
|
||||
.writer-recent{padding:0;list-style:none}.writer-recent li{padding:.7rem 0;border-bottom:1px solid var(--pd-border,#ccc);display:flex;gap:1rem;justify-content:space-between;font-size:.85rem}.writer-recent span{max-width:60ch}
|
||||
/* Working intention is the primary action; evidence remains a compact summary. */
|
||||
.writer-heading{justify-content:flex-start}.writer-heading>div:not(.writer-book-cover):not(.writer-connection){flex:1}.writer-book-cover{width:76px;height:108px;object-fit:cover;border-radius:5px;box-shadow:0 6px 18px #0002;flex-shrink:0}.writer-cover-fallback{display:grid;place-items:center;background:var(--pd-primary,#576b78);color:#fff;font:2.5rem Georgia,serif;border-left:6px solid #ffffff40}
|
||||
.writer-next-grid{grid-template-columns:minmax(0,2fr) minmax(230px,1fr)}.writer-start{border-top:4px solid var(--pd-primary,#576b78)}.writer-start-paths{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1rem;margin:1.3rem 0}.writer-path{display:flex;flex-direction:column;gap:.6rem;padding:1rem;border-left:3px solid var(--pd-primary,#576b78);background:var(--surface-alt,#8881);text-decoration:none;color:inherit}.writer-path:hover{background:#8882}.writer-path span{font-size:.9rem}.writer-objective-form{display:grid;gap:1rem;margin-top:1rem}.writer-objective-form label{display:grid;gap:.4rem}.writer-progress{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin:1rem 0}.writer-progress .writer-workflow-strip{grid-column:1/-1}.writer-workflow-strip{display:flex;flex-wrap:wrap;gap:1rem}.writer-workflow-strip a{text-decoration:none;padding:.5rem .8rem;background:#8881;border-radius:20px}.writer-workflow-strip strong{font-size:1.2rem;margin-right:.3rem}.writer-change-track{height:22px;display:flex;border-radius:12px;overflow:hidden;background:#8882;margin:1rem 0}.writer-change-added{background:#418a73}.writer-change-removed{background:#bd795d}.writer-journey-compact .writer-calendar{display:flex;gap:5px;flex-wrap:wrap}.writer-journey-compact .writer-day{width:18px;height:18px;min-height:18px;padding:0;border-radius:4px}.writer-journey-compact .writer-empty{margin-bottom:.5rem}
|
||||
@media(max-width:900px){.writer-next-grid{grid-template-columns:1fr}.writer-start-paths{grid-template-columns:1fr}.writer-progress{grid-template-columns:1fr}.writer-heading{flex-wrap:wrap}.writer-heading .writer-connection{width:100%}.writer-book-cover{width:52px;height:74px}}
|
||||
.writer-progress{border:0;background:linear-gradient(120deg,var(--pd-surface,#ffffff10),#8881);padding-block:1.5rem}.writer-progress h2{font-size:1.65rem}.writer-workflow-progress{display:flex;height:9px;border-radius:8px;overflow:hidden;grid-column:1/-1;background:#8882}.writer-stage-WriteNext{background:#9eabc2}.writer-stage-InProgress{background:#ad8a55}.writer-stage-Revision{background:#916884}.writer-stage-FinalPass{background:#538879}.writer-journey-compact{border:0;background:transparent;padding:1rem 0;box-shadow:none}.writer-journey-compact h2{font-size:1.4rem}.writer-journey-compact .writer-section-heading{margin-bottom:.7rem}.writer-queue-details>summary{cursor:pointer;margin-block:.8rem}.writer-queue-details[open]>summary{margin-bottom:1.2rem}.writer-next-grid>article:not(.writer-current):not(.writer-start){border:0;border-left:1px solid #8885;border-radius:0;background:transparent;box-shadow:none}
|
||||
|
||||
14
PlotLine/wwwroot/js/writer-objective.js
Normal file
14
PlotLine/wwwroot/js/writer-objective.js
Normal file
@ -0,0 +1,14 @@
|
||||
(() => {
|
||||
document.querySelector('[data-open-objective]')?.addEventListener('click', () => { document.getElementById('objective-setup').open = true; });
|
||||
const chapter = document.querySelector('[data-objective-chapter]'), scene = document.querySelector('[data-objective-scene]');
|
||||
if (!chapter || !scene) return;
|
||||
const filter = () => {
|
||||
for (const option of scene.options) {
|
||||
option.hidden = Boolean(option.value && option.dataset.chapter !== chapter.value);
|
||||
option.disabled = option.hidden;
|
||||
}
|
||||
if (scene.selectedOptions[0]?.disabled) scene.value = '';
|
||||
scene.disabled = !chapter.value;
|
||||
};
|
||||
chapter.addEventListener('change', filter); filter();
|
||||
})();
|
||||
@ -98,6 +98,16 @@
|
||||
fill(intentDisplaySelect, baseIntent, currentIntent);
|
||||
};
|
||||
|
||||
let nativePresence = document.querySelector('#native-companion-status')?.nativePresence;
|
||||
const renderCompanion = () => {
|
||||
if (root.dataset.compactWriter !== "true" || !nativePresence) return;
|
||||
if (document.querySelector('#native-companion-status')?.dataset.nativeAuthority === 'false') return;
|
||||
const linked = nativePresence.some(lease => lease.wordAvailable && Number(lease.bookId) === fallbackScope.bookID);
|
||||
text(statusNodes.word, nativePresence.connectionState === 'Connected'
|
||||
? (linked ? 'Connected · linked manuscript open' : 'Connected · no linked manuscript open')
|
||||
: (nativePresence.connectionState === 'Disconnected' ? 'Disconnected' : nativePresence.connectionState));
|
||||
};
|
||||
window.addEventListener('native-companion-presence', event => { nativePresence = event.detail; renderCompanion(); });
|
||||
const render = (status = latestStatus) => {
|
||||
const incomingScope = workspace.statusScope(status);
|
||||
if (status && ((activeScope.projectID && incomingScope.projectID && activeScope.projectID !== incomingScope.projectID)
|
||||
@ -105,7 +115,8 @@
|
||||
// Presence broadcasts cover all this author's books. They must not change
|
||||
// the workspace chosen here by a canonical position or explicit command.
|
||||
if(root.dataset.compactWriter === "true"){if(startButton)startButton.hidden=true;root.dataset.linkedDocument="false";}
|
||||
text(statusNodes.word, status.wordCompanionConnected || status.WordCompanionConnected ? "Connected" : "Not connected");
|
||||
text(statusNodes.word, status.wordCompanionConnected || status.WordCompanionConnected ? "Linked manuscript open" : "No linked manuscript open");
|
||||
renderCompanion();
|
||||
return;
|
||||
}
|
||||
if (root.dataset.compactWriter === "true") {
|
||||
@ -117,8 +128,9 @@
|
||||
latestStatus = status;
|
||||
activeScope = workspace.statusScope(status, activeScope);
|
||||
text(statusNodes.book, activeScope.bookID ? `Book ${activeScope.bookID}` : "Waiting for book");
|
||||
text(statusNodes.word, status?.wordCompanionConnected || status?.WordCompanionConnected ? "Connected" : "Not connected");
|
||||
text(statusNodes.word, status?.wordCompanionConnected || status?.WordCompanionConnected ? "Linked manuscript open" : "No linked manuscript open");
|
||||
if(root.dataset.compactWriter === "true" && (status?.wordCompanionConnected || status?.WordCompanionConnected) && root.dataset.linkedDocument !== "true") text(statusNodes.word,"Connected · no linked document");
|
||||
renderCompanion();
|
||||
text(statusNodes.context, statusText(status, "Context"));
|
||||
text(statusNodes.intent, statusText(status, "Intent"));
|
||||
const contextOpen = statusText(status, "Context") !== "Not open";
|
||||
@ -255,7 +267,8 @@
|
||||
updateDisplayOptions(screenInfo);
|
||||
text(statusNodes.layout, screenInfo.layout?.mode || "adaptive");
|
||||
}).catch(error => {
|
||||
text(statusNodes.word, "Unavailable");
|
||||
text(statusNodes.word, "Status unavailable");
|
||||
renderCompanion();
|
||||
text(statusNodes.context, "Unavailable");
|
||||
text(statusNodes.intent, "Unavailable");
|
||||
setMessage("Writing workspace presence is unavailable. Check your connection and retry opening a reference window; other PlotDirector sections remain available.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user