Build purposeful Writer workflows on existing focus, investigation and journey services
This commit is contained in:
parent
8347f34f28
commit
63fb2d5a75
15
PlotLine.Tests/Browser/writer-phase2.cjs
Normal file
15
PlotLine.Tests/Browser/writer-phase2.cjs
Normal file
@ -0,0 +1,15 @@
|
||||
// Real Development acceptance. Requires a private disposable identity; never run against Production.
|
||||
const {chromium}=require('playwright'),fs=require('fs'),assert=require('node:assert/strict');
|
||||
const w=JSON.parse(fs.readFileSync(process.env.PD_WRITER2_IDENTITY)),base='https://dev.plotdirector.com',before=process.env.PD_WRITER2_STAGE==='before',out=process.env.PD_WRITER2_SCREENSHOTS;
|
||||
(async()=>{const browser=await chromium.launch();try{const context=await browser.newContext({viewport:{width:1440,height:1000}});await context.addInitScript(u=>{Object.defineProperty(navigator,'standalone',{value:true});localStorage.setItem('plotdirector.desktop.v1.'+u,JSON.stringify({dismissedAt:Date.now()}));},w.UserID);const p=await context.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));
|
||||
await p.goto(base+'/Account/Login');await p.locator('[name=Email]').fill(w.Email);await p.locator('[name=Password]').fill(w.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);
|
||||
const route=(d,b=w.book,project=w.project)=>`${base}/Writer/${d}?projectId=${project}${b?'&bookId='+b:''}`;
|
||||
const shot=async n=>{if(!out)return;fs.mkdirSync(out,{recursive:true});await p.mouse.move(2,995);await p.waitForTimeout(200);await p.screenshot({path:out+'/'+n+'.png',animations:'disabled'});};
|
||||
for(const [label,book,project] of [['Populated',w.book,w.project],['Minimal',w.otherBook,w.project],['Structured',w.structuredBook,w.project],['No-book',null,w.emptyProject]])for(const d of ['Write','Explore','Plan','Review','Reflect']){const r=await p.goto(route(d,book,project));assert.equal(r.status(),200,label+d);if(!before&&book&&d==='Reflect')await p.locator('.writer-month-grid').waitFor();if(!before&&book&&d==='Explore')await p.locator('[data-investigation-opening] input[name=concern]').first().waitFor();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),label+d+' overflow');await shot(label+'-'+d);}
|
||||
if(before){console.log('PASS baseline authenticated four-fixture captures');return;}
|
||||
await p.goto(route('Write'));const exportSessions=async()=>await(await p.request.get(base+`/Writer/Work/Export?bookId=${w.book}`)).json();const sessionsBefore=await exportSessions();const form=p.locator('[data-focus-wizard]');if(!await form.isVisible())await p.locator('[data-change-focus]').click();await form.locator('[name=Activity]').selectOption('Revising');await form.locator('[data-focus-next]').click();await form.locator('[name=ChapterID]').selectOption(String(w.chapter));await form.locator('[name=SceneID]').selectOption(String(w.scene));await form.locator('[data-focus-next]').click();await form.locator('[name=Intention]').fill('Clarify the turning point');await form.locator('[data-focus-back]').click();assert.equal(await form.locator('[name=ChapterID]').inputValue(),String(w.chapter));await form.locator('[data-focus-next]').click();assert.equal(await form.locator('[name=Intention]').inputValue(),'Clarify the turning point');let saves=0;p.on('request',r=>{if(r.method()==='POST'&&new URL(r.url()).pathname==='/Writer/SaveObjective')saves++;});await form.evaluate(n=>{n.requestSubmit();n.requestSubmit();});await p.locator('[data-focus-summary]').filter({hasText:'Clarify the turning point'}).waitFor();assert.equal(saves,1);assert.deepEqual(await exportSessions(),sessionsBefore,'focus must not create sessions');await shot('Write-established');await p.goto(route('Plan'));assert((await p.locator('.writer3-main').textContent()).includes('Clarify the turning point'));await p.goto(route('Write'));assert((await p.locator('[data-focus-summary]').textContent()).includes('Clarify the turning point'));await p.locator('[data-change-focus]').click();await form.locator('[data-focus-next]').click();await form.locator('[name=ChapterID]').selectOption('');await form.locator('[data-focus-next]').click();await form.locator('[data-save-focus]').click();await p.locator('[data-focus-summary]').filter({hasText:'Across the book'}).waitFor();assert.deepEqual(await exportSessions(),sessionsBefore);
|
||||
await p.goto(route('Explore'));await p.locator('[data-discovery-tiles] [data-tile]:visible').first().waitFor();const tile=p.locator('[data-discovery-tiles] [data-tile]:visible').first(),id=await tile.getAttribute('data-tile');await tile.locator('[data-dismiss]').click();assert(await p.locator(`[data-tile="${id}"]`).isHidden());await p.reload();assert(await p.locator(`[data-tile="${id}"]`).isHidden());await p.locator('[data-reconsider]').click();assert(await p.locator(`[data-tile="${id}"]`).isVisible());await p.locator(`[data-tile="${id}"] [data-defer]`).click();assert(await p.locator(`[data-tile="${id}"]`).isHidden());await p.locator('[data-reconsider]').click();await p.locator('[data-investigation-opening] input[name=concern]').first().check();await p.locator('[data-investigation-opening] button[type=submit]').click();await p.waitForURL(/Investigate\?bookId=.*id=/);assert(await p.locator('[data-investigation-answer]').isVisible());await p.goto(route('Explore'));await p.locator('[data-my-investigations] article').first().waitFor();const completed=p.locator('[data-my-investigations] article').filter({hasText:'Original results'}).first();await completed.getByRole('button',{name:'Continue',exact:true}).click();await p.locator('.investigation form[data-guidance-navigation]').first().locator('button').click();await p.locator('[data-investigation-companion] #guidance-finding').waitFor();assert.equal(context.pages().length,1);await p.locator('[data-guidance-pin]').click();await p.goto(route('Explore'));await p.locator('[data-discovery-active] form').first().waitFor();await p.evaluate(()=>PlotLineHelpDrawer.open('writer3.explore'));await p.locator('.help-drawer-article').waitFor();await shot('Explore-both-panels');
|
||||
await p.goto(route('Review')+'&chapterId='+w.chapter);await p.locator('[data-review-intentions-slot] [data-review-intentions]').waitFor();assert(await p.locator('.reader-page').isVisible());const paragraph=p.locator('[data-paragraph-id][data-scene-id]').filter({hasText:'recorded first paragraph'}).first();await paragraph.click();await p.locator('[data-review-record]').click();await p.locator('[data-review-cancel]').click();await p.locator('[data-review-intentions-slot]').getByText('Disposable review scene',{exact:true}).waitFor();await shot('Review-context');await p.locator('#reader-focus').click();await p.locator('#reader-next').click();assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');await p.locator('#reader-focus').click();await p.goto(route('Review')+'&reading=true&chapterId='+w.chapter);assert.equal(await p.locator('.manuscript-reader').getAttribute('data-reading'),'true');await shot('Reading-mode');
|
||||
await p.goto(route('Reflect'));await p.locator('.writer-month-grid').waitFor();const month=await p.locator('.writer-section-heading h2').first().textContent();await p.getByRole('link',{name:'Previous month',exact:true}).click();assert(p.url().includes('/Writer/Reflect'));assert.notEqual(await p.locator('.writer-section-heading h2').first().textContent(),month);await p.locator('.writer-month-grid a').first().click();assert(p.url().includes('day='));await shot('Reflect-day');
|
||||
for(const width of [1920,1366,800])for(const d of ['Write','Explore','Plan','Review','Reflect']){await p.setViewportSize({width,height:1000});await p.goto(route(d));await p.evaluate(()=>PlotLineHelpDrawer.open('writer3.layout'));await p.locator('.help-drawer-article').waitFor();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),d+' '+width);await shot(d+'-'+width+'-panels');const collapse=p.locator('[data-ribbon-collapse]');await collapse.click();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));if(await p.locator('[data-guidance-collapse]').isVisible())await p.locator('[data-guidance-collapse]').click();await p.locator('[data-help-collapse]').count().then(async n=>{if(n)await p.locator('[data-help-collapse]').click();});await shot(d+'-'+width+'-collapsed');}
|
||||
assert.deepEqual(errors,[]);console.log('PASS Phase 2 authenticated four fixtures, AJAX focus and no sessions, discovery preferences, canonical questionnaire, saved guidance, Review/Reading/Focus scene context, Reflect month/day, three widths and panel/ribbon states');await context.close();}finally{await browser.close();}})().catch(e=>{console.error(e.stack);process.exitCode=1});
|
||||
45
PlotLine.Tests/Sql/WriterPhase2Focus.sql
Normal file
45
PlotLine.Tests/Sql/WriterPhase2Focus.sql
Normal file
@ -0,0 +1,45 @@
|
||||
-- Development only; isolated transactional fixtures roll back.
|
||||
IF DB_NAME()<>N'PlotDirector_Development' THROW 51000,'Wrong database',1;
|
||||
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();
|
||||
DECLARE @sessions bigint=(SELECT COUNT_BIG(*) FROM dbo.WriterWorkSessions);
|
||||
EXEC dbo.WriterObjective @u,@b,'save',@c,@scene,'Revising',N'Clarify the turning point';
|
||||
IF NOT EXISTS(SELECT 1 FROM dbo.WriterWorkingObjectives WHERE BookID=@b AND UserID=@u AND Intention=N'Clarify the turning point') THROW 51001,'Intention not retained',1;
|
||||
IF (SELECT COUNT_BIG(*) FROM dbo.WriterWorkSessions)<>@sessions THROW 51001,'Focus created a session',1;
|
||||
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;
|
||||
@ -36,7 +36,7 @@ public sealed class WriterController(
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public Task<IActionResult> Reflect(int? projectId, int? bookId = null) => LoadDestination("Reflect", projectId, bookId);
|
||||
public Task<IActionResult> Reflect(int? projectId, int? bookId = null, int? year=null, int? month=null, DateTime? day=null) => LoadDestination("Reflect", projectId, bookId, journey:true, year:year, month:month, day:day);
|
||||
public Task<IActionResult> Dashboard(int? projectId, int? bookId = null) => LoadDestination("Dashboard", projectId, bookId);
|
||||
public Task<IActionResult> Overview(int? projectId, int? bookId = null) => LoadDestination("Legacy", projectId, bookId);
|
||||
|
||||
@ -127,9 +127,21 @@ public sealed class WriterController(
|
||||
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(Write), new { bookId = model.BookID, setup = true }); }
|
||||
if(Request.Headers["X-Requested-With"]=="XMLHttpRequest") {
|
||||
var confirmed=(await objectives.Read(author,model.BookID)).Objective!;
|
||||
return Json(new { saved=true, activity=confirmed.Activity, chapterID=confirmed.ChapterID, sceneID=confirmed.SceneID, title=confirmed.SceneTitle??confirmed.ChapterTitle??"Across the book", intention=confirmed.Intention, sessionKind=PlotLine.Services.Writer.WriterFocusActivities.SessionKind(confirmed.Activity), continueUrl=confirmed.SceneID.HasValue?Url.Action("Edit","Scenes",new{id=confirmed.SceneID}):confirmed.ChapterID.HasValue?Url.Action("Chapter",new{id=confirmed.ChapterID}):Url.Action("Details","Books",new{id=model.BookID}), inspectUrl=confirmed.ChapterID.HasValue?Url.Action("Inspect","WriterAuthoring",new{bookId=model.BookID,chapterId=confirmed.ChapterID,sceneId=confirmed.SceneID}):null });
|
||||
}
|
||||
return scheduleNow ? RedirectToAction(nameof(ScheduleSetup), new { bookId = model.BookID }) : RedirectToAction(nameof(Write), new { bookId = model.BookID });
|
||||
}
|
||||
|
||||
[HttpGet, ResponseCache(NoStore=true,Location=ResponseCacheLocation.None)]
|
||||
public async Task<IActionResult> Focus(int bookId)
|
||||
{
|
||||
if(access==null||!await access.CanAccessEntityAsync("Book",bookId)||objectives==null)return NotFound();
|
||||
var saved=await objectives.Read(int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!),bookId);
|
||||
return PartialView("_WriterFocusForm",new WriterDashboardViewModel {BookID=bookId,Objective=saved.Objective,ObjectiveChoices=saved.Choices});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Chapter(int id)
|
||||
{
|
||||
var model = await writerWorkspace.GetChapterWorkflowAsync(id);
|
||||
|
||||
@ -28,6 +28,11 @@ public sealed class WriterInvestigationsController(InvestigationAccess gate,IInv
|
||||
ViewData["SavedConcernLabels"]=labels;
|
||||
return View(new InvestigationPage(row,c,state,saved,project,bookId));
|
||||
});
|
||||
[HttpGet]
|
||||
public Task<IActionResult> Opening(int bookId)=>Guard(async()=>{
|
||||
var project=await service.Project(bookId);var c=await service.AuthorCatalogue()??throw new ArgumentException("The investigation catalogue is unavailable.");await EnsureCatalogue(c);
|
||||
return PartialView("_Opening",new InvestigationPage(null,c,null,[],project,bookId));
|
||||
});
|
||||
[HttpPost("/Writer/Explore/Investigate/Start"),ValidateAntiForgeryToken]
|
||||
public Task<IActionResult> Start(int bookId,string concern,string? catalogueVersion=null)=>Guard(async()=>{if(catalogueVersion!=null&&!await IsAdmin())return NotFound();var c=await (catalogueVersion==null?service.AuthorCatalogue():repository.Catalogue(catalogueVersion))??throw new ArgumentException("The investigation catalogue is unavailable.");await EnsureCatalogue(c);var row=await service.Start(Author,bookId,concern,c.Version);return RedirectToAction(nameof(Index),new{bookId,id=row.ID});});
|
||||
[HttpPost("/Writer/Explore/Investigate/Answer"),ValidateAntiForgeryToken]
|
||||
|
||||
@ -13,6 +13,6 @@ public sealed class WriterObjectiveRepository(ISqlConnectionFactory factory)
|
||||
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);
|
||||
await db.ExecuteAsync("dbo.WriterObjective", new { UserID = user, value.BookID, value.ChapterID, value.SceneID, value.Activity, value.Intention, Action = "save" }, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,8 @@ public sealed class WriterObjective
|
||||
public int? SceneID { get; set; }
|
||||
[Required, RegularExpression("^(Drafting|Revising|Editing|Researching|Proofreading)$")]
|
||||
public string Activity { get; set; } = "Drafting";
|
||||
[StringLength(2000)]
|
||||
public string? Intention { get; set; }
|
||||
public string? ChapterTitle { get; set; }
|
||||
public string? SceneTitle { get; set; }
|
||||
}
|
||||
|
||||
37
PlotLine/Sql/280_WriterFocusIntention.sql
Normal file
37
PlotLine/Sql/280_WriterFocusIntention.sql
Normal file
@ -0,0 +1,37 @@
|
||||
SET ANSI_NULLS ON;
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
IF COL_LENGTH('dbo.WriterWorkingObjectives','Intention') IS NULL ALTER TABLE dbo.WriterWorkingObjectives ADD Intention nvarchar(2000) NULL;
|
||||
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, @Intention nvarchar(2000)=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.Intention,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,Intention=@Intention,UpdatedUtc=SYSUTCDATETIME() WHERE BookID=@BookID AND UserID=@UserID;
|
||||
ELSE INSERT dbo.WriterWorkingObjectives(BookID,UserID,ChapterID,SceneID,Activity,Intention) VALUES(@BookID,@UserID,@ChapterID,@SceneID,@Activity,@Intention);
|
||||
COMMIT;
|
||||
END;
|
||||
GO
|
||||
@ -22,11 +22,12 @@
|
||||
}
|
||||
</div>
|
||||
@section Scripts {
|
||||
<script src="~/js/writer2-workspaces.js" asp-append-version="true"></script>
|
||||
<script src="~/js/writer3-workspace.js" asp-append-version="true"></script>
|
||||
<script src="~/js/writing-workspace.js" asp-append-version="true"></script>
|
||||
<script src="~/js/writing-workspace-launcher.js" asp-append-version="true"></script>
|
||||
@if(Model.Destination=="Review"){<script src="~/js/manuscript-reader.js" asp-append-version="true"></script><script src="~/js/writer-review.js" asp-append-version="true"></script><script src="~/js/writer-word.js" asp-append-version="true"></script><script src="~/js/writer-work.js" asp-append-version="true"></script>}
|
||||
@if(Model.Destination == "Write"){
|
||||
@if(Model.Destination is "Write" or "Plan"){
|
||||
<script src="~/js/writer-word.js" asp-append-version="true"></script>
|
||||
<script src="~/js/writer-authoring.js" asp-append-version="true"></script>
|
||||
<script src="~/js/writer-focus.js" asp-append-version="true"></script>
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
@model WriterDashboardViewModel
|
||||
@{var work=Model.Work??new PlotLine.Models.WriterWorkPage{BookID=Model.BookID??0};var first=new DateTime(work.Year,work.Month,1);var offset=((int)first.DayOfWeek+6)%7;var days=work.Days.ToDictionary(x=>x.Day.Date);var maximum=Math.Max(1,days.Values.Select(x=>x.Intensity).DefaultIfEmpty(1).Max());int Level(PlotLine.Models.WriterWorkDay? day)=>day==null||day.Intensity==0?0:Math.Clamp((int)Math.Ceiling(day.Intensity*4d/maximum),1,4);string Description(PlotLine.Models.WriterWorkDay? value)=>value==null?"No retained activity":$"{value.Changes} accepted changes; {value.Writing+value.Editing} writing/editing sessions; {value.Planning} planning sessions; {value.Reading} reading sessions; {value.EngagedSeconds} browser-engaged seconds; {value.PlaybackSeconds:0} observed audio seconds";var previous=first.AddMonths(-1);var next=first.AddMonths(1);}
|
||||
<section class="writer-card" aria-label="Writing Journey calendar">
|
||||
<div class="writer-section-heading"><h2>@first.ToString("MMMM yyyy")</h2><div class="button-row"><a asp-action="Journey" asp-route-bookId="@work.BookID" asp-route-year="@previous.Year" asp-route-month="@previous.Month">Previous month</a><a asp-action="Journey" asp-route-bookId="@work.BookID" asp-route-year="@next.Year" asp-route-month="@next.Month">Next month</a></div></div>
|
||||
<p>Green shows relative observed activity, including revision with zero net growth. Unavailable audio without playback evidence does not add listening activity. Neutral days mean no retained observation. Receipt dates use UTC; historical coverage is incomplete.</p>
|
||||
<div class="writer-month-grid">@foreach(var name in new[]{"Mon","Tue","Wed","Thu","Fri","Sat","Sun"}){<strong>@name</strong>}@for(var i=0;i<offset;i++){<span></span>}@for(var date=first;date.Month==first.Month;date=date.AddDays(1)){days.TryGetValue(date,out var day);<a class="work-level-@Level(day) @(work.Day?.Date==date?"writer-day-selected":"")" asp-action="Journey" asp-route-bookId="@work.BookID" asp-route-year="@date.Year" asp-route-month="@date.Month" asp-route-day="@date.ToString("yyyy-MM-dd")" aria-label="@date.ToString("d MMMM yyyy"): @Description(day)"><strong>@date.Day</strong>@if(day!=null){<small>+@day.Added / −@day.Removed words</small>@if(day.Writing>0||day.Editing>0){<small>Writing / editing</small>}@if(day.EngagedSeconds>=60){<small>@Math.Floor(day.EngagedSeconds/60d) browser-engaged min</small>}@if(day.Planning>0){<small>Planning</small>}@if(day.Reading>0){<small>Reading review</small>}@if(day.AudioReview>0){<small>Audio review · @Math.Floor(day.PlaybackSeconds/60) observed min</small>}}</a>}</div>
|
||||
<details><summary>@work.Year year overview</summary><div class="writer-year-grid">@for(var date=new DateTime(work.Year,1,1);date.Year==work.Year;date=date.AddDays(1)){days.TryGetValue(date,out var day);<a class="work-level-@Level(day)" asp-action="Journey" asp-route-bookId="@work.BookID" asp-route-year="@date.Year" asp-route-month="@date.Month" asp-route-day="@date.ToString("yyyy-MM-dd")" aria-label="@date.ToString("d MMM yyyy"): @Description(day)" title="@date.ToString("d MMM"): @Description(day)"></a>}</div></details>
|
||||
<div class="writer-section-heading"><h2>@first.ToString("MMMM yyyy")</h2><div class="button-row"><a asp-action="@(Model.Destination=="Reflect"?"Reflect":"Journey")" asp-route-bookId="@work.BookID" asp-route-year="@previous.Year" asp-route-month="@previous.Month">Previous month</a><a asp-action="@(Model.Destination=="Reflect"?"Reflect":"Journey")" asp-route-bookId="@work.BookID" asp-route-year="@next.Year" asp-route-month="@next.Month">Next month</a></div></div>
|
||||
<p>Colour shows relative recorded activity, including revision. Select a date to explore it. A quiet day here does not establish that no writing took place.</p><details><summary>What this calendar records</summary><p>Accepted manuscript changes are observed automatically. Sessions are started explicitly by you; their elapsed time is separate from observed browser or audio activity. Earlier or imported writing may not have tracking history. Dates use UTC.</p></details>
|
||||
<div class="writer-month-grid">@foreach(var name in new[]{"Mon","Tue","Wed","Thu","Fri","Sat","Sun"}){<strong>@name</strong>}@for(var i=0;i<offset;i++){<span></span>}@for(var date=first;date.Month==first.Month;date=date.AddDays(1)){days.TryGetValue(date,out var day);<a class="work-level-@Level(day) @(work.Day?.Date==date?"writer-day-selected":"")" asp-action="@(Model.Destination=="Reflect"?"Reflect":"Journey")" asp-route-bookId="@work.BookID" asp-route-year="@date.Year" asp-route-month="@date.Month" asp-route-day="@date.ToString("yyyy-MM-dd")" aria-label="@date.ToString("d MMMM yyyy"): @Description(day)"><strong>@date.Day</strong>@if(day!=null){<small>+@day.Added / −@day.Removed words</small>@if(day.Writing>0||day.Editing>0){<small>Writing / editing</small>}@if(day.EngagedSeconds>=60){<small>@Math.Floor(day.EngagedSeconds/60d) browser-engaged min</small>}@if(day.Planning>0){<small>Planning</small>}@if(day.Reading>0){<small>Reading review</small>}@if(day.AudioReview>0){<small>Audio review · @Math.Floor(day.PlaybackSeconds/60) observed min</small>}}</a>}</div>
|
||||
<details><summary>@work.Year year overview</summary><div class="writer-year-grid">@for(var date=new DateTime(work.Year,1,1);date.Year==work.Year;date=date.AddDays(1)){days.TryGetValue(date,out var day);<a class="work-level-@Level(day)" asp-action="@(Model.Destination=="Reflect"?"Reflect":"Journey")" asp-route-bookId="@work.BookID" asp-route-year="@date.Year" asp-route-month="@date.Month" asp-route-day="@date.ToString("yyyy-MM-dd")" aria-label="@date.ToString("d MMM yyyy"): @Description(day)" title="@date.ToString("d MMM"): @Description(day)"></a>}</div></details>
|
||||
@if(work.Day is {} selected){days.TryGetValue(selected.Date,out var observed);<h3 class="mt-3">@selected.ToString("d MMMM yyyy")</h3>@if(observed==null){<p>No retained observation for this day. This does not establish that no work took place.</p>}else{<p>@observed.Changes accepted changes · +@observed.Added / −@observed.Removed words · @(observed.Added-observed.Removed) net.</p><p>@Math.Floor(observed.EngagedSeconds/60d) browser-engaged minutes · @Math.Floor(observed.PlaybackSeconds/60) observed playback minutes. These may overlap and are not added.</p>}<a asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@work.BookID" asp-route-day="@selected.ToString("yyyy-MM-dd")">Accepted-change evidence</a>}
|
||||
<h3 class="mt-3">@(work.Day.HasValue?"Sessions on this day":"Recent sessions")</h3>
|
||||
@foreach(var session in work.Sessions.Take(20)){<article class="writer-reminder"><strong>@session.Kind · @(session.ChapterTitle??(session.ChapterID.HasValue?"Chapter no longer available":"Whole book"))</strong><p>@session.StartedUtc.ToString("d MMM HH:mm") UTC · @session.EngagedSeconds browser-engaged seconds · @Math.Round(session.PlaybackSeconds) observed playback seconds · @Math.Round(session.UniqueSeconds) unique audio seconds.</p>@if(session.EndedUtc.HasValue){<span>@Math.Round((session.EndedUtc.Value-session.StartedUtc).TotalMinutes) minutes elapsed (not active time).</span>}@if(session.ChangesDuringSession>0){<p>@session.ChangesDuringSession accepted changes during this interval · +@session.AdditionsDuringSession / −@session.RemovalsDuringSession words across the book · @session.ChangedParagraphs changed paragraph identities associated with this chapter. Overlap in time does not prove that playback caused edits.</p>}@if(session.StartRevision.HasValue){<p>Accepted checkpoint @session.StartRevision → @(session.EndRevision?.ToString()??"session open") · @session.StartParagraphCount → @(session.EndParagraphCount?.ToString()??"—") paragraphs (whole book).</p>}@if(session.Note!=null){<p>@session.Note</p>}</article>}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
@model PlotLine.Services.Writer.ReviewPanel
|
||||
@{var data=Model.Intentions;var goal=data.Sections.First(x=>x.Kind=="Goals");var scene=data.Sections.FirstOrDefault(x=>x.Kind=="Scene");string Compact(string value)=>value.Length>360?value[..360]+"…":value;}
|
||||
<div data-review-panel>
|
||||
<section class="writer3-inset"><h3>What did I want this to achieve?</h3><p class="writer3-caption">@Model.ReferenceMessage</p>
|
||||
<div data-review-panel><p class="writer3-caption">@Model.ReferenceMessage</p>
|
||||
<section class="writer3-inset" data-review-intentions><h3>Chapter and scene intentions</h3>
|
||||
@if(scene!=null){<h4>@data.Scene?.SceneTitle</h4><p class="review-recorded">@(string.IsNullOrWhiteSpace(scene.Value("ScenePurposeNotes"))?"No scene intention recorded.":Compact(scene.Value("ScenePurposeNotes")))</p><p class="review-recorded">@Compact(scene.Value("SceneOutcomeNotes"))</p><p class="writer3-caption">Recorded scene state: @data.Scene?.RevisionStatusName</p>}
|
||||
<p class="review-recorded">@(string.IsNullOrWhiteSpace(goal.Value("GoalSummary"))?"No chapter intention recorded. You can review without one.":Compact(goal.Value("GoalSummary")))</p>
|
||||
<details><summary>Chapter details, reminders & editing</summary>
|
||||
|
||||
@ -1,27 +1,23 @@
|
||||
@inject PlotLine.Services.Investigations.InvestigationAccess InvestigationAccess
|
||||
@model WriterDashboardViewModel
|
||||
<div class="writer3-workspace" aria-label="Story exploration">
|
||||
<section class="writer3-panel writer3-main" tabindex="0">
|
||||
@if(InvestigationAccess.Enabled && Model.BookID.HasValue){<section class="writer3-inset"><h2>What's troubling you about your story?</h2><p>You don't need to know the answer yet. Work through a concern one question at a time.</p><a class="btn btn-primary" asp-controller="WriterInvestigations" asp-action="Index" asp-route-bookId="@Model.BookID">Explore a concern</a><p class="writer3-caption">Explore your concern through questions and practical writing actions. Suggestions use your answers, not manuscript analysis.</p></section>}
|
||||
@if(InvestigationAccess.Enabled&&Model.BookID.HasValue){<section class="writer3-inset" data-my-investigations data-book="@Model.BookID" data-url="@Url.Action("Saved","InvestigationCompanion")"><h2>My Investigations</h2><p>Continue a saved concern or revisit its original results.</p><div class="pd-investigation-list" data-saved-investigations><p>Loading your saved investigations…</p></div></section>}
|
||||
<p class="eyebrow">Start with your question</p><h2>What would you like to explore?</h2><p>You do not need a finished outline or a linked manuscript. Choose a starting point.</p>
|
||||
<div class="writer3-explore-paths">
|
||||
<a asp-controller="Writer" asp-action="Write" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID"><span class="writer3-path-mark" aria-hidden="true">01</span><div><h3>Develop a chapter or scene</h3><p>Work with your saved chapter intentions, scene ideas and reminders.</p></div><span aria-hidden="true">→</span></a>
|
||||
<a asp-controller="@(Model.ProjectID.HasValue?"PlotLineWorkspace":"Projects")" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID"><span class="writer3-path-mark" aria-hidden="true">02</span><div><h3>Develop your plot and threads</h3><p>Use your existing plot lines and threads to develop an idea or untangle a concern.</p></div><span aria-hidden="true">→</span></a>
|
||||
@if(Model.BookID.HasValue){<a asp-controller="Timeline" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID"><span class="writer3-path-mark" aria-hidden="true">03</span><div><h3>Look at your story’s shape</h3><p>Inspect your saved chapters, scenes and story timeline.</p></div><span aria-hidden="true">→</span></a>}
|
||||
</div>
|
||||
<p class="writer3-caption">These open your authenticated writing and story tools. No manuscript analysis runs here.</p>
|
||||
</section>
|
||||
<aside class="writer3-panel writer3-reference" tabindex="0" aria-label="Existing story references">
|
||||
<h2>Your story references</h2>
|
||||
@if(Model.ProjectID.HasValue){<div class="writer3-link-list">
|
||||
<a asp-controller="Characters" asp-action="Index" asp-route-projectId="@Model.ProjectID">Characters <span aria-hidden="true">↗</span></a>
|
||||
<a asp-controller="RelationshipMap" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Relationships <span aria-hidden="true">↗</span></a>
|
||||
<a asp-controller="PlotLineWorkspace" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Plot Lines & threads <span aria-hidden="true">↗</span></a>
|
||||
<a asp-controller="Maps" asp-action="Index" asp-route-projectId="@Model.ProjectID">Maps <span aria-hidden="true">↗</span></a>
|
||||
<a asp-controller="FloorPlans" asp-action="Index" asp-route-projectId="@Model.ProjectID">Floor Plans <span aria-hidden="true">↗</span></a>
|
||||
<a asp-controller="ProjectMetrics" asp-action="Index" asp-route-projectId="@Model.ProjectID">Emotion & scene metrics <span aria-hidden="true">↗</span></a>
|
||||
</div><p class="writer3-caption">These open the existing Story, Characters and World workspaces. Project-wide tools may include other books in this project.</p>}
|
||||
else{<p>Select a project in the application bar to inspect its characters, plot and world. Your existing writing tools will use the selected project and book.</p><a asp-controller="Projects" asp-action="Index">Open your projects</a>}
|
||||
</aside>
|
||||
<div class="writer3-workspace writer2-explore" aria-label="Story exploration">
|
||||
<section class="writer3-panel" data-discovery data-owner="@User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value" data-book="@Model.BookID" data-project="@Model.ProjectID">
|
||||
<h2>Discover what could help your story</h2><p>Find a practical next step, or try a different way of looking at your work.</p>
|
||||
@if(Model.ProjectID.HasValue){
|
||||
<div data-discovery-active></div><div data-discovery-tiles>
|
||||
@foreach(var suggestion in Model.Suggestions.Where(x=>x.Key!="explore").Take(2)){
|
||||
<article class="writer2-tile" data-tile="suggestion-@suggestion.Key" data-rank="80"><h3>@suggestion.Action</h3><p>@suggestion.Observation</p><a asp-controller="@suggestion.Controller" asp-action="@suggestion.RouteAction" asp-route-id="@suggestion.EntityID" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID" asp-route-chapterId="@suggestion.ChapterID">@suggestion.Action</a><div class="button-row"><button type="button" data-defer>Later</button><button type="button" data-dismiss>Not now</button></div></article>}
|
||||
<article class="writer2-tile" data-tile="chapters" data-rank="@(Model.ObjectiveChoices.Count==0?95:40)"><h3>Give your writing a place</h3><p>@(Model.ObjectiveChoices.Count==0?"No chapters are recorded here yet. Add one when you want to organise your writing in PlotDirector.":"Your chapters and scenes are available. Develop their intentions or continue an outline.")</p><a asp-controller="@(Model.BookID.HasValue?"Books":"Projects")" asp-action="Details" asp-route-id="@(Model.BookID??Model.ProjectID)" asp-fragment="chapters">@(Model.BookID.HasValue?"Work with chapters and scenes":"Choose or create a book")</a><div class="button-row"><button type="button" data-defer>Later</button><button type="button" data-dismiss>Not now</button></div></article>
|
||||
<article class="writer2-tile" data-tile="characters" data-rank="65"><h3>Understand the people in your story</h3><p>Record what matters about your characters, whether you are starting out or deepening a draft.</p><a asp-controller="Characters" asp-action="Index" asp-route-projectId="@Model.ProjectID">Develop your characters</a><div class="button-row"><button type="button" data-defer>Later</button><button type="button" data-dismiss>Not now</button></div></article>
|
||||
<article class="writer2-tile" data-tile="plot-lines-threads" data-rank="@(Model.ObjectiveChoices.Count>0?70:50)"><h3>Connect what happens</h3><p>Trace your plot lines and threads alongside the story you have recorded.</p><a asp-controller="PlotLineWorkspace" asp-action="Index" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Explore plot lines and threads</a><div class="button-row"><button type="button" data-defer>Later</button><button type="button" data-dismiss>Not now</button></div></article>
|
||||
<article class="writer2-tile" data-tile="floor-plans" data-rank="20"><h3>Picture the space around a scene</h3><p>A floor plan can help you think about rooms, positions and movement.</p><a asp-controller="FloorPlans" asp-action="Index" asp-route-projectId="@Model.ProjectID">Explore floor plans</a><div class="button-row"><button type="button" data-defer>Later</button><button type="button" data-dismiss>Not now</button></div></article>
|
||||
</div><button type="button" class="btn btn-link" data-reconsider>Reconsider hidden suggestions</button><p data-discovery-message role="status"></p>
|
||||
}else{<p>Choose a project to discover tools for its characters, settings and story.</p><a class="btn btn-primary" asp-controller="Projects" asp-action="Index">Choose or create a project</a>}
|
||||
</section>
|
||||
<section class="writer3-panel" aria-label="Explore a concern"><h2>Explore a concern</h2><p>You do not need to know the answer yet. Start with what is troubling you.</p>
|
||||
@if(InvestigationAccess.Enabled&&Model.BookID.HasValue){
|
||||
<div data-investigation-opening data-url="@Url.Action("Opening","WriterInvestigations",new{bookId=Model.BookID})"><p>Loading starting concerns…</p><a asp-controller="WriterInvestigations" asp-action="Index" asp-route-bookId="@Model.BookID">Open Guided Investigation</a></div>
|
||||
<section class="writer3-inset" data-my-investigations data-book="@Model.BookID" data-url="@Url.Action("Saved","InvestigationCompanion")"><h2>My Investigations</h2><p>Continue a saved concern or revisit its original results.</p><div class="pd-investigation-list" data-saved-investigations><p>Loading your saved investigations…</p></div></section>
|
||||
}else{<p>@(Model.BookID.HasValue?"Guided Investigation is not available in this environment. The story tools remain available.":"Select a book to keep your concerns and investigations with that book.")</p>}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
@model WriterDashboardViewModel
|
||||
@{ var objective = Model.Objective; }
|
||||
<form asp-action="SaveObjective" method="post" class="writer-objective-form" data-focus-form>
|
||||
<input type="hidden" name="BookID" value="@Model.BookID" />
|
||||
<label>What am I doing?<select class="form-select" name="Activity" data-focus-activity>
|
||||
@foreach(var activity in PlotLine.Services.Writer.WriterFocusActivities.ObjectiveKinds){<option value="@activity" data-session-kind="@PlotLine.Services.Writer.WriterFocusActivities.SessionKind(activity)" selected="@(objective?.Activity==activity)">@activity</option>}
|
||||
</select></label>
|
||||
<label>Which chapter?<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>Which scene? (optional)<select class="form-select" name="SceneID" data-objective-scene><option value="">No scene selected</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 type="submit" class="btn btn-primary" data-save-focus>Save working focus</button>@if(!Model.ActivityIsPrivate){<button type="button" class="btn btn-outline-primary" data-record-focus disabled>Record this session</button>}<button type="button" class="btn btn-outline-secondary" data-plan-focus>Plan writing time</button></div>
|
||||
@{var objective=Model.Objective;}
|
||||
<form asp-action="SaveObjective" asp-controller="Writer" method="post" class="writer-objective-form" data-focus-form data-focus-wizard>
|
||||
<input type="hidden" name="BookID" value="@Model.BookID" />
|
||||
<p data-focus-step-label role="status">Step 1 of 3</p>
|
||||
<fieldset data-focus-step="0"><legend>What are you doing?</legend>
|
||||
<label>Activity<select class="form-select" name="Activity" data-focus-activity>@foreach(var activity in PlotLine.Services.Writer.WriterFocusActivities.ObjectiveKinds){<option value="@activity" data-session-kind="@PlotLine.Services.Writer.WriterFocusActivities.SessionKind(activity)" selected="@(objective?.Activity==activity)">@activity</option>}</select></label>
|
||||
<p>Choose your intended work. This does not start a recording.</p></fieldset>
|
||||
<fieldset data-focus-step="1" hidden><legend>Where are you working?</legend>
|
||||
<label>Chapter<select class="form-select" name="ChapterID" data-objective-chapter><option value="">Across the book</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="">Across this chapter</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>
|
||||
@if(Model.ObjectiveChoices.Count==0){<p>You can work across the book now, or <a asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID" asp-fragment="chapters">add a chapter or scene</a> when you need one.</p>}</fieldset>
|
||||
<fieldset data-focus-step="2" hidden><legend>What do you want to achieve?</legend><label>Intention (optional)<textarea class="form-control" name="Intention" maxlength="2000" rows="3">@objective?.Intention</textarea></label><p>A short reminder of what matters in this piece of work.</p><p data-focus-confirmation></p></fieldset>
|
||||
<p data-focus-error role="alert"></p><div class="button-row"><button type="button" class="btn btn-outline-secondary" data-focus-back hidden>Back</button><button type="button" class="btn btn-primary" data-focus-next>Continue</button><button type="submit" class="btn btn-primary" data-save-focus hidden>Save focus</button><button type="button" class="btn btn-link" data-focus-cancel>Cancel</button></div>
|
||||
</form>
|
||||
<p class="writer3-caption">Saving does not start recording. Planning opens this book’s existing schedule setup; chapter and scene allocations are chosen there. Planning does not save this selection.</p>
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
@model WriterDashboardViewModel
|
||||
<div class="writer3-workspace" aria-label="Writing plans">
|
||||
<section class="writer3-panel writer3-main" tabindex="0">
|
||||
<p class="eyebrow">Make room for your writing</p><h2>Plan your next writing time</h2><p>Use your existing chapters and scenes to choose activities and working budgets. Detailed scene estimates are optional.</p>
|
||||
<a class="btn btn-primary writer3-cta" asp-action="ScheduleSetup" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Create a writing plan <span aria-hidden="true">→</span></a>
|
||||
<div class="writer3-inset"><h3>Work ahead</h3><partial name="_WriterUpcoming" model="Model" /></div>
|
||||
</section>
|
||||
<aside class="writer3-panel writer3-reference" tabindex="0">
|
||||
<h2>Your existing plans</h2><div class="writer3-link-list">
|
||||
<a asp-action="WritingPlans" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Manage writing plans <span aria-hidden="true">↗</span></a>
|
||||
<a asp-action="SchedulePreview" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Preview & adjust a schedule <span aria-hidden="true">↗</span></a>
|
||||
<a asp-action="Dashboard" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Writing Dashboard <span aria-hidden="true">↗</span></a>
|
||||
</div><p class="writer3-caption">Reviewed chapter/scene activities and existing workflow tasks remain available. Completing a planned task is your declaration, separate from measured work and scene status.</p>
|
||||
</aside>
|
||||
<div class="writer3-workspace writer2-single" aria-label="Writing priorities">
|
||||
<section class="writer3-panel writer3-main" data-writer-focus data-book-id="@Model.BookID" data-focus-url="@Url.Action("Focus","Writer",new{bookId=Model.BookID})">
|
||||
<h2>Next activities</h2><p>Choose what deserves your attention next. Dates and schedules are optional.</p>
|
||||
<section class="writer3-inset"><h3>Your next intended work</h3>
|
||||
@if(Model.Objective is {} focus){<p><strong>@focus.Activity · @(focus.SceneTitle??focus.ChapterTitle??"Across the book")</strong></p>@if(!string.IsNullOrWhiteSpace(focus.Intention)){<p class="review-recorded">@focus.Intention</p>}<a class="btn btn-primary" asp-action="Write" asp-route-bookId="@Model.BookID">Continue this work</a>}
|
||||
else{<p>Start with one piece of work you would like to continue. It does not need a deadline.</p>}
|
||||
<a class="btn btn-outline-secondary" asp-action="Write" asp-route-bookId="@Model.BookID" asp-route-setup="true" data-change-focus>@(Model.Objective==null?"Choose next work":"Change next work")</a>
|
||||
<div id="objective-setup" hidden></div><p class="writer3-caption">This is your saved writing focus, not a completed task or a recorded session.</p></section>
|
||||
@if(Model.PlannedActivities.Count>0){<h3>Scheduled writing activities</h3><ol class="writer2-activities">@foreach(var item in Model.PlannedActivities.Take(12)){<li><time>@item.ScheduledDate.ToString("ddd d MMM")</time><strong>@item.Kind · @item.Title</strong><span>@item.Status · @item.Minutes planned minutes</span>@if(item.SceneID.HasValue){<a asp-controller="Scenes" asp-action="Edit" asp-route-id="@item.SceneID">Work on this scene</a>}else{<a asp-action="Chapter" asp-route-id="@item.ChapterID">Work on this chapter</a>}</li>}</ol>}
|
||||
else{<h3>Writing time ahead</h3><partial name="_WriterUpcoming" model="Model" />}
|
||||
<details class="writer3-inset"><summary>Schedule and completed work</summary><p>@Model.WritingSchedule.CompletedTasks completed · @Model.WritingSchedule.SkippedTasks skipped · @Model.WritingSchedule.RemainingTasks outstanding scheduled tasks. These are recorded task states, not measured manuscript progress.</p>
|
||||
<div class="button-row"><a asp-action="SchedulePreview" asp-route-bookId="@Model.BookID" asp-route-projectId="@Model.ProjectID">View and adjust your schedule</a><a asp-action="WritingPlans" asp-route-bookId="@Model.BookID" asp-route-projectId="@Model.ProjectID">Existing plans and activity completion</a><a asp-action="ScheduleSetup" asp-route-bookId="@Model.BookID" asp-route-projectId="@Model.ProjectID">@(Model.WritingSchedule.HasActivePlans?"Create another writing plan":"Create a writing schedule")</a></div></details>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
@model WriterDashboardViewModel
|
||||
<div class="writer3-workspace" aria-label="Writing reflection">
|
||||
<section class="writer3-panel writer3-main" tabindex="0"><p class="eyebrow">Your recorded progress</p><h2>See what has changed</h2><partial name="_WriterProgress" model="Model" /><a class="btn btn-primary writer3-cta" asp-action="Journey" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Open Writing Journey <span aria-hidden="true">→</span></a></section>
|
||||
<aside class="writer3-panel writer3-reference" tabindex="0"><h2>Your writing history</h2><div class="writer3-link-list">
|
||||
<a asp-action="Journey" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Calendar, sessions & return notes <span aria-hidden="true">↗</span></a>
|
||||
@if(!Model.ActivityIsPrivate){<a asp-controller="WritingActivity" asp-action="Index" asp-route-bookId="@Model.BookID">Reports, privacy & exports <span aria-hidden="true">↗</span></a>}
|
||||
<a asp-action="Dashboard" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Writing Dashboard <span aria-hidden="true">↗</span></a>
|
||||
</div><p class="writer3-caption">Writing Process and reflective insights are planned for a later update. No working style or writing quality is inferred here.</p></aside>
|
||||
</div>
|
||||
<div class="writer3-workspace writer2-single" aria-label="Writing reflection"><section class="writer3-panel writer3-main">
|
||||
@if(Model.ActivityIsPrivate){<p>Recorded activity is private to the book owner. Your chapter and scene tools remain available.</p>}
|
||||
else{
|
||||
<h2>Your writing journey</h2><p>Look back at recorded work, explore a day, or notice how your writing has changed over time.</p>
|
||||
@if(Model.Work?.Days.Any(x=>x.Intensity>0)!=true&&Model.Work?.Sessions.Count==0){<p>Your journey will grow as writing sessions and manuscript changes are recorded. Quiet days here do not mean you did no writing.</p><div class="button-row"><a class="btn btn-primary" asp-action="Write" asp-route-bookId="@Model.BookID">Continue writing or record a session</a></div>}
|
||||
<partial name="_JourneyCalendar" model="Model" />
|
||||
<details class="writer3-inset"><summary>Recorded manuscript progress</summary><partial name="_WriterProgress" model="Model" /></details>
|
||||
}
|
||||
</section></div>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
@{var reader=Model.ReviewReader;var word=new WriterDashboardViewModel{BookID=Model.BookID,ProjectID=Model.ProjectID,WordNavigationContext="review",Objective=reader?.Chapter==null?null:new(){ChapterID=reader.Chapter.ChapterID,ChapterTitle=reader.Chapter.ChapterTitle,Activity="Revising"}};}
|
||||
<div class="writer3-workspace" aria-label="Manuscript review">
|
||||
<section class="writer3-panel writer3-main" tabindex="0" aria-label="Accepted manuscript">
|
||||
<details class="writer2-chapter-context" open><summary>Chapter intentions and verified scene context</summary><div data-review-intentions-slot><p>Loading recorded intentions…</p></div></details>
|
||||
@if(reader!=null){<partial name="~/Views/ManuscriptReader/_Reader.cshtml" model="reader" />}
|
||||
else{<h2>Read the accepted manuscript</h2><p>Select a book with chapters to review your accepted writing.</p><a asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID">Open your book</a>}
|
||||
</section>
|
||||
|
||||
@ -1,28 +1,31 @@
|
||||
@model WriterDashboardViewModel
|
||||
@{var focus = Model.Objective; var editing = Context.Request.Query["setup"] == "true"; var kind = focus?.Activity is "Revising" or "Editing" or "Proofreading" ? "Editing" : focus?.Activity == "Researching" ? "Planning" : "Writing";}
|
||||
<div class="writer3-workspace" aria-label="Writing workspace">
|
||||
<section class="writer3-panel writer3-main" tabindex="0" id="working-focus" aria-label="Current writing focus" data-writer-focus data-saved-activity="@focus?.Activity" data-saved-session-kind="@PlotLine.Services.Writer.WriterFocusActivities.SessionKind(focus?.Activity)" data-saved-chapter="@focus?.ChapterID" data-book-id="@Model.BookID" data-plan-url="@Url.Action("ScheduleSetup", "Writer", new { bookId = Model.BookID, projectId = Model.ProjectID })">
|
||||
<section class="writer3-panel writer3-main" tabindex="0" id="working-focus" aria-label="Current writing focus" data-writer-focus data-focus-url="@Url.Action("Focus","Writer",new{bookId=Model.BookID})" data-saved-activity="@focus?.Activity" data-saved-session-kind="@PlotLine.Services.Writer.WriterFocusActivities.SessionKind(focus?.Activity)" data-saved-chapter="@focus?.ChapterID" data-book-id="@Model.BookID" data-plan-url="@Url.Action("ScheduleSetup", "Writer", new { bookId = Model.BookID, projectId = Model.ProjectID })">
|
||||
<p class="eyebrow">Your current work</p>
|
||||
<div data-focus-summary>
|
||||
@if(focus != null && !editing){
|
||||
<h2>@(focus.SceneTitle ?? focus.ChapterTitle ?? "Your manuscript")</h2><p class="writer3-focus-kind">@focus.Activity</p>@if(focus.ChapterID.HasValue){<p class="writer3-caption">Chapter: @focus.ChapterTitle</p>}<p>Write manuscript prose in Word; use the intentions and reminders below to guide your work.</p>
|
||||
<h2>@(focus.SceneTitle ?? focus.ChapterTitle ?? "Your manuscript")</h2><p class="writer3-focus-kind">@focus.Activity</p>@if(focus.ChapterID.HasValue){<p class="writer3-caption">Chapter: @focus.ChapterTitle</p>}@if(!string.IsNullOrWhiteSpace(focus.Intention)){<p class="review-recorded">@focus.Intention</p>}<p>Keep your intention here; write manuscript prose in Word.</p>
|
||||
<div class="button-row">
|
||||
@if(focus.SceneID.HasValue){<a class="btn btn-primary writer3-cta" asp-controller="Scenes" asp-action="Edit" asp-route-id="@focus.SceneID">Open current scene <span aria-hidden="true">→</span></a>}
|
||||
else if(focus.ChapterID.HasValue){<a class="btn btn-primary writer3-cta" asp-action="Chapter" asp-route-id="@focus.ChapterID">Open current chapter <span aria-hidden="true">→</span></a>}
|
||||
else{<a class="btn btn-primary writer3-cta" asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID" asp-fragment="chapters">Open your chapters <span aria-hidden="true">→</span></a>}
|
||||
<a asp-action="Write" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID" asp-route-setup="true">Change working focus</a>
|
||||
</div>
|
||||
}else{
|
||||
<h2>@(editing ? "Choose your working focus" : "Where would you like to begin?")</h2><p>Choose an activity and, if you like, a chapter or scene. You can start without a writing plan.</p>
|
||||
<div id="objective-setup"><partial name="_WriterFocusForm" model="Model" /></div>
|
||||
|
||||
}
|
||||
|
||||
</div>
|
||||
<button type="button" class="btn btn-link" data-change-focus>Change focus</button>
|
||||
<div id="objective-setup" hidden="@(focus!=null&&!editing)">@if(focus==null||editing){<partial name="_WriterFocusForm" model="Model" />}</div>
|
||||
@if(!Model.ActivityIsPrivate){
|
||||
@if(focus != null && !editing){<div class="button-row writer3-focus-actions"><button type="button" class="btn btn-outline-primary" data-record-focus disabled>Record this session</button><button type="button" class="btn btn-outline-secondary" data-plan-focus>Plan writing time</button></div>}
|
||||
<label data-record-kind-choice hidden>Record proofreading as<select class="form-select" data-record-kind><option value="">Choose a compatible recording activity</option><option value="Editing">Editing</option><option value="Reading">Reading review</option></select></label>
|
||||
<p class="writer3-caption" data-focus-recording-hint></p><p role="status" data-focus-message></p><p class="writer3-caption" data-focus-session-difference hidden></p>
|
||||
<div class="writer3-session-block"><h3>Work sessions & Audio Review</h3><p class="writer3-caption">Recording keeps your saved working focus. Audio Review is recorded for a chapter.</p><partial name="_WriterWorkToolbar" model="new PlotLine.Models.WriterWorkToolbar(Model.BookID!.Value, focus?.ChapterID, focus?.ChapterTitle, Model.ObjectiveChoices, kind, true)" /></div>}
|
||||
else{<p class="muted">Work-session evidence is private to the book owner. Your chapter and scene tools remain available.</p>}
|
||||
@if(focus?.ChapterID.HasValue==true && !editing){<div class="writer3-authoring" data-writer-authoring data-inspect-url="@Url.Action("Inspect","WriterAuthoring",new{bookId=Model.BookID,chapterId=focus.ChapterID,sceneId=focus.SceneID})" aria-live="polite"><p>Loading your recorded intentions…</p></div>}
|
||||
<div class="writer3-authoring" data-writer-authoring data-inspect-url="@(focus?.ChapterID.HasValue==true?Url.Action("Inspect","WriterAuthoring",new{bookId=Model.BookID,chapterId=focus.ChapterID,sceneId=focus.SceneID}):null)" aria-live="polite"><p>Loading your recorded intentions…</p></div>
|
||||
</section>
|
||||
<aside class="writer3-panel writer3-reference" tabindex="0" aria-label="Writing tools">
|
||||
<h2>Keep your story close</h2><div class="button-row writer3-window-actions"><button type="button" class="btn btn-sm btn-outline-secondary" data-open-writing-context>Open Context <span aria-hidden="true">↗</span></button><button type="button" class="btn btn-sm btn-outline-secondary" data-open-writing-intent>Open Intent <span aria-hidden="true">↗</span></button></div><p data-writing-workspace-message role="status"></p><partial name="_WriterWord" model="Model" /><div data-authoring-references></div><p>Open the existing tools when you need more detail.</p>
|
||||
|
||||
@ -13,11 +13,7 @@
|
||||
<div class="writer3-workspace">
|
||||
<section class="writer3-panel" aria-labelledby="investigation-question">
|
||||
@if(row==null){
|
||||
<h2 id="investigation-question">@(Model.Catalogue.Editorial is {} editorial?Model.Catalogue.Questions.Single(q=>q.Id==editorial.OpeningQuestion).Text:"What's troubling you about your story?")</h2>
|
||||
@if(Model.Catalogue.Editorial is {} opening){<p>@Model.Catalogue.Questions.Single(q=>q.Id==opening.OpeningQuestion).Help</p>}
|
||||
<form asp-action="Start" method="post"><input type="hidden" name="bookId" value="@Model.BookID" />@if(Model.Catalogue.Synthetic){<input type="hidden" name="catalogueVersion" value="@Model.Catalogue.Version" />}<fieldset><legend class="visually-hidden">Choose a starting concern</legend>
|
||||
@foreach(var concern in Model.Catalogue.Concerns){<label class="investigation-choice"><input type="radio" name="concern" value="@concern.Id" required /> @concern.Text</label>}
|
||||
</fieldset><button class="btn btn-primary" type="submit">Begin</button></form>
|
||||
<partial name="_Opening" model="Model" />
|
||||
}else if(question!=null){
|
||||
<p class="writer3-caption">@row.Answers.Count questions answered · There is no fixed number needed for a useful next step.</p>
|
||||
<h2 id="investigation-question">@question.Text</h2>@if(question.Help!=""){<p id="question-help">@question.Help</p>}
|
||||
|
||||
6
PlotLine/Views/WriterInvestigations/_Opening.cshtml
Normal file
6
PlotLine/Views/WriterInvestigations/_Opening.cshtml
Normal file
@ -0,0 +1,6 @@
|
||||
@model PlotLine.Models.Investigations.InvestigationPage
|
||||
<h2 id="investigation-question">@(Model.Catalogue.Editorial is {} editorial?Model.Catalogue.Questions.Single(q=>q.Id==editorial.OpeningQuestion).Text:"What's troubling you about your story?")</h2>
|
||||
@if(Model.Catalogue.Editorial is {} opening){<p>@Model.Catalogue.Questions.Single(q=>q.Id==opening.OpeningQuestion).Help</p>}
|
||||
<form asp-controller="WriterInvestigations" asp-action="Start" method="post"><input type="hidden" name="bookId" value="@Model.BookID" />@if(Model.Catalogue.Synthetic){<input type="hidden" name="catalogueVersion" value="@Model.Catalogue.Version" />}<fieldset><legend class="visually-hidden">Choose a starting concern</legend>
|
||||
@foreach(var concern in Model.Catalogue.Concerns){<label class="investigation-choice"><input type="radio" name="concern" value="@concern.Id" required /> @concern.Text</label>}
|
||||
</fieldset><button class="btn btn-primary" type="submit">Begin</button></form>
|
||||
@ -105,3 +105,16 @@
|
||||
.writer3-destination:has(.manuscript-reader[data-reading=true]) .writer3-split{grid-template-columns:minmax(0,1fr)}
|
||||
.writer3-destination:has(.manuscript-reader[data-reading=true]) .writer3-reference,.writer3-destination:has(.manuscript-reader[data-reading=true]) .writer3-divider{display:none!important}
|
||||
.writer3-destination:has(.manuscript-reader[data-reading=true]) [data-review-record],.manuscript-reader[data-reading=true]>.reader-metadata,.manuscript-reader[data-reading=true]>details,.manuscript-reader[data-reading=true]>footer{display:none}
|
||||
|
||||
/* Phase 2 working surfaces use the accepted shared shell and theme. */
|
||||
.writer2-single{display:block}.writer2-single>.writer3-main{width:100%;max-width:none}
|
||||
.writer2-explore{grid-template-columns:repeat(2,minmax(0,1fr));align-items:start}
|
||||
.writer2-explore>.writer3-panel{min-width:0;max-height:none;overflow:visible}
|
||||
.writer2-tile{border-block-start:1px solid var(--pd-border);padding:1rem 0}.writer2-tile h3{font-size:1.2rem}.writer2-tile .button-row{margin-top:.6rem}.writer2-tile button:not(.btn){border:0;background:none;color:var(--pd-accent);text-decoration:underline;padding:.3rem}
|
||||
[data-focus-wizard] fieldset{min-width:0;border:0;padding:.5rem 0}[data-focus-wizard] legend{font-size:1.15rem}[data-focus-wizard] label{display:block;margin:.6rem 0}[data-focus-wizard] textarea{width:100%}
|
||||
.writer2-activities{padding-left:1.4rem}.writer2-activities li{padding:1rem;border-bottom:1px solid var(--pd-border)}.writer2-activities li>*{display:block}
|
||||
.writer2-chapter-context{margin-bottom:1rem}.writer2-chapter-context>summary{cursor:pointer;color:var(--pd-accent)}
|
||||
.writer3-destination:has(.manuscript-reader[data-reading=true]) .writer2-chapter-context{display:none}
|
||||
@container (min-width:1200px){.writer3-main:has(.writer2-chapter-context){display:grid;grid-template-columns:minmax(180px, .28fr) minmax(0,1fr);gap:1rem;align-items:start}.writer2-chapter-context{position:sticky;top:var(--writer-sticky-top,8px);min-width:0}.writer3-main:has(.writer2-chapter-context)>.manuscript-reader{min-width:0}.writer3-main:has(.manuscript-reader[data-reading=true]){display:block}}
|
||||
.writer3-destination .writer3-workspace{container-type:inline-size}
|
||||
@media(max-width:1050px){.writer2-explore{grid-template-columns:minmax(0,1fr)}}
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
const priorId=current?.id;const stamp=++epoch;request?.abort();request=new AbortController();
|
||||
try{const url=new URL(root.dataset.summaryUrl,location.origin);if(root.dataset.project)url.searchParams.set('projectId',root.dataset.project);if(root.dataset.book)url.searchParams.set('bookId',root.dataset.book);
|
||||
const response=await fetch(url,{cache:'no-store',signal:request.signal});if(response.redirected||response.status===401){throw Error('Sign in again to resume your saved investigation.');}if(!response.ok)throw Error('Saved guidance could not be loaded. Retry when your connection returns.');const data=await response.json();if(stamp!==epoch)return;
|
||||
current=data.active?data.summary:null;hasSnapshot=data.hasSnapshot!==false;resultsUrl=data.resultsUrl;preference=read();render();restorePanel(!hydrated||priorId!==current?.id);hydrated=true;
|
||||
current=data.active?data.summary:null;hasSnapshot=data.hasSnapshot!==false;resultsUrl=data.resultsUrl;preference=read();render();restorePanel(!hydrated||priorId!==current?.id);hydrated=true;window.dispatchEvent(new CustomEvent("plotdirector:guidance-summary",{detail:data}));
|
||||
}catch(e){if(e.name==='AbortError'||stamp!==epoch)return;current=null;content.replaceChildren(element('p',e.message),btn('Retry',load),startLink());panel.hide();}
|
||||
}
|
||||
async function mutate(operation,extra={}){
|
||||
|
||||
@ -36,10 +36,11 @@
|
||||
}
|
||||
function replaceCard(card,doc){const fresh=doc.querySelector(`[data-key="${CSS.escape(card.dataset.key)}"]`);if(!fresh)throw Error('Saved record is not available');const clone=fresh.cloneNode(true),parent=card.parentElement;card.replaceWith(clone);bind(parent);clone.querySelector('[data-authoring-status]').textContent='Saved.';clone.querySelector('[data-authoring-edit]')?.focus();}
|
||||
async function read(){const response=await fetch(root.dataset.inspectUrl,{cache:'no-store'});if(!response.ok)throw Error('Recorded information is unavailable');const doc=new DOMParser().parseFromString(await response.text(),'text/html');if(!doc.querySelector('[data-authoring-content]'))throw Error('Authorisation or recorded information is unavailable');return doc;}
|
||||
async function load(){try{const doc=await read();root.replaceChildren(...doc.body.childNodes);bind(root);const references=document.querySelector('[data-authoring-references]'),template=root.querySelector('[data-authoring-companion]');if(references&&template)references.replaceChildren(template.content.cloneNode(true));}
|
||||
async function load(){if(!root.dataset.inspectUrl){root.replaceChildren();return;}try{const doc=await read();root.replaceChildren(...doc.body.childNodes);bind(root);const references=document.querySelector('[data-authoring-references]'),template=root.querySelector('[data-authoring-companion]');if(references&&template)references.replaceChildren(template.content.cloneNode(true));}
|
||||
catch{root.replaceChildren();const p=document.createElement('p');p.textContent='Recorded information could not load. Your current work and existing editors remain available.';const retry=document.createElement('button');retry.type='button';retry.className='btn btn-outline-secondary';retry.textContent='Try again';retry.addEventListener('click',load);root.append(p,retry);}}
|
||||
window.addEventListener('beforeunload',e=>{if(dirty()&&!allowLeave){e.preventDefault();e.returnValue='';}});
|
||||
function guard(e){if(!dirty())return;const target=e.target.closest('a,form,[data-plan-focus]');if(!target||target.matches('[data-authoring-form],[data-work-start]')||target.target==='_blank'||target.hasAttribute('download'))return;if(target.tagName==='A'&&new URL(target.href,location.href).pathname===location.pathname&&new URL(target.href,location.href).search===location.search&&target.hash)return;if(!confirm(root.querySelector('[data-busy="true"]')?'A save is in progress and may finish after you leave. Leave this page?':'Leave without saving your inline edits?')){e.preventDefault();e.stopImmediatePropagation();}else allowLeave=true;}
|
||||
document.addEventListener('click',e=>{if(e.target.closest('a,[data-plan-focus]'))guard(e);},true);document.addEventListener('submit',guard,true);window.addEventListener('pageshow',()=>allowLeave=false);
|
||||
window.addEventListener('plotdirector:focus-saved',e=>{root.dataset.inspectUrl=e.detail.inspectUrl||'';void load();});
|
||||
load();
|
||||
})();
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
root.addEventListener('plotdirector:work-start-finished',()=>{pending=false;render();});
|
||||
activity?.addEventListener('change',()=>{if(kindChoice)kindChoice.value='';render();});kindChoice?.addEventListener('change',render);
|
||||
record?.addEventListener('click',()=>{if(active||pending||!known)return;const s=selection(),k=kind();if(!k){message.textContent='Choose a compatible session activity before recording.';kindChoice?.focus();return;}message.textContent='';pending=true;render();root.querySelector('[data-writer-work]').dispatchEvent(new CustomEvent('plotdirector:record-focus',{detail:{kind:k,chapter:s.chapter}}));});
|
||||
form?.addEventListener('submit',e=>{if(e.defaultPrevented)return;if(saving||!objectives.includes(selection().activity)){e.preventDefault();return;}saving=true;render();});
|
||||
form?.addEventListener('submit',e=>{if(e.defaultPrevented||form.hasAttribute('data-focus-wizard'))return;if(saving||!objectives.includes(selection().activity)){e.preventDefault();return;}saving=true;render();});
|
||||
root.querySelector('[data-plan-focus]')?.addEventListener('click',()=>{const url=new URL(root.dataset.planUrl,location.origin);url.searchParams.set('focusActivity',selection().activity);location.assign(url);});
|
||||
render();
|
||||
})();
|
||||
|
||||
@ -1,14 +1,18 @@
|
||||
(() => {
|
||||
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();
|
||||
const root=document.querySelector('[data-writer-focus]'); if(!root)return;
|
||||
const host=root.querySelector('#objective-setup');let loading=false;
|
||||
function initialise(){const form=host.querySelector('[data-focus-wizard]');if(!form)return;let step=0,busy=false;
|
||||
const chapter=form.querySelector('[data-objective-chapter]'),scene=form.querySelector('[data-objective-scene]');
|
||||
function filter(){for(const o of scene.options){o.hidden=!!o.value&&o.dataset.chapter!==chapter.value;o.disabled=o.hidden;}if(scene.selectedOptions[0]?.disabled)scene.value='';scene.disabled=!chapter.value;}
|
||||
function render(){form.querySelectorAll('[data-focus-step]').forEach((x,i)=>x.hidden=i!==step);form.querySelector('[data-focus-back]').hidden=step===0;form.querySelector('[data-focus-next]').hidden=step===2;form.querySelector('[data-save-focus]').hidden=step!==2;form.querySelector('[data-focus-step-label]').textContent=`Step ${step+1} of 3`;form.querySelector('[data-focus-confirmation]').textContent=`Save ${form.elements.Activity.value.toLowerCase()} · ${scene.value?scene.selectedOptions[0].textContent:chapter.selectedOptions[0].textContent}. No session will be recorded.`;}
|
||||
chapter.addEventListener('change',filter);filter();render();
|
||||
for(const [selector,direction] of [['[data-focus-next]',1],['[data-focus-back]',-1]])form.querySelector(selector).addEventListener('click',()=>{step+=direction;render();form.querySelector('[data-focus-step]:not([hidden]) select, [data-focus-step]:not([hidden]) textarea')?.focus();});
|
||||
form.querySelector('[data-focus-cancel]').addEventListener('click',()=>{host.hidden=true;root.querySelector('[data-change-focus]')?.focus();});
|
||||
form.addEventListener('submit',async e=>{e.preventDefault();if(e.defaultPrevented&&e.cancelBubble)return;if(busy)return;if(step!==2){step++;render();return;}busy=true;const button=form.querySelector('[data-save-focus]');button.disabled=true;form.querySelector('[data-focus-error]').textContent='';try{const response=await fetch(form.action,{method:'POST',body:new FormData(form),headers:{'X-Requested-With':'XMLHttpRequest'}});if(!response.ok)throw Error();const data=await response.json();if(!data.saved)throw Error();
|
||||
root.dataset.savedActivity=data.activity;root.dataset.savedChapter=data.chapterID||'';root.dataset.savedSessionKind=data.sessionKind||'';
|
||||
let summary=root.querySelector('[data-focus-summary]');if(!summary){summary=document.createElement('div');host.before(summary);}summary.replaceChildren();const h=document.createElement('h2');h.textContent=data.activity+' · '+data.title;const p=document.createElement('p');p.textContent=data.intention||'Your focus is saved. No recording has started.';const a=document.createElement('a');a.href=data.continueUrl;a.className='btn btn-primary';a.textContent='Continue this work';summary.append(h,p,a);host.hidden=true;busy=false;button.disabled=false;
|
||||
window.dispatchEvent(new CustomEvent('plotdirector:focus-saved',{detail:data}));summary.tabIndex=-1;summary.focus();}catch{form.querySelector('[data-focus-error]').textContent='Your focus could not be confirmed. Your choices are retained; please try again.';busy=false;button.disabled=false;}});
|
||||
}
|
||||
root.querySelector('[data-change-focus]')?.addEventListener('click',async e=>{e.preventDefault();if(loading)return;if(host.querySelector('form')){host.hidden=false;return;}loading=true;host.hidden=false;host.textContent='Loading your focus…';try{const r=await fetch(root.dataset.focusUrl);if(!r.ok)throw Error();host.innerHTML=await r.text();initialise();}catch{host.textContent='Focus is temporarily unavailable. Try Change focus again.';}finally{loading=false;}});
|
||||
initialise();
|
||||
})();
|
||||
|
||||
@ -7,7 +7,7 @@ const nodeParagraph=n=>(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.close
|
||||
function capture(){const s=getSelection();if(!s||s.isCollapsed||s.rangeCount!==1)return null;const r=s.getRangeAt(0),first=nodeParagraph(r.startContainer),last=nodeParagraph(r.endContainer);if(!first||!last||!readerContent.contains(first)||!readerContent.contains(last))return null;const before=document.createRange();before.selectNodeContents(first);before.setEnd(r.startContainer,r.startOffset);const after=document.createRange();after.selectNodeContents(last);after.setEnd(r.endContainer,r.endOffset);return{StartParagraph:first.dataset.paragraphId,EndParagraph:last.dataset.paragraphId,StartOffset:before.toString().length,EndOffset:after.toString().length};}
|
||||
function wordReference(id){if(!word)return;word.dataset.paragraphId=id||'';word.dataset.acceptedRevision=reader.dataset.revision;window.dispatchEvent(new Event('review-reference-changed'));}
|
||||
function queueContext(){clearTimeout(selectionTimer);selectionTimer=setTimeout(()=>void load(false),180);}
|
||||
async function load(force=true){clearTimeout(selectionTimer);const key=[selected,anchor?.EndParagraph,reader.dataset.version,page].join(':');if(!force&&key===lastContext)return;const mine=++generation;controller?.abort();controller=new AbortController();loading=true;const url=new URL(root.dataset.panelUrl,location.href);url.search=new URLSearchParams({bookId:root.dataset.book,chapterId:root.dataset.chapter,version:reader.dataset.version,page:String(page),...(selected?{paragraphId:selected,endParagraphId:anchor?.EndParagraph||selected}:{})});try{const response=await fetch(url,{cache:'no-store',signal:controller.signal});if(!response.ok)throw Error();const doc=new DOMParser().parseFromString(await response.text(),'text/html'),panel=doc.querySelector('[data-review-panel]');if(!panel)throw Error();if(mine===generation){context.replaceChildren(panel);lastContext=key;}}catch(e){if(e.name!=='AbortError'&&mine===generation){message.textContent='Recorded review information could not load. Your observation text is retained.';}}finally{if(mine===generation)loading=false;}}
|
||||
async function load(force=true){clearTimeout(selectionTimer);const key=[selected,anchor?.EndParagraph,reader.dataset.version,page].join(':');if(!force&&key===lastContext)return;const mine=++generation;controller?.abort();controller=new AbortController();loading=true;const url=new URL(root.dataset.panelUrl,location.href);url.search=new URLSearchParams({bookId:root.dataset.book,chapterId:root.dataset.chapter,version:reader.dataset.version,page:String(page),...(selected?{paragraphId:selected,endParagraphId:anchor?.EndParagraph||selected}:{})});try{const response=await fetch(url,{cache:'no-store',signal:controller.signal});if(!response.ok)throw Error();const doc=new DOMParser().parseFromString(await response.text(),'text/html'),panel=doc.querySelector('[data-review-panel]');if(!panel)throw Error();if(mine===generation){context.replaceChildren(panel);const slot=document.querySelector('[data-review-intentions-slot]');if(slot&&panel.querySelector('[data-review-intentions]'))slot.replaceChildren(panel.querySelector('[data-review-intentions]'));lastContext=key;}}catch(e){if(e.name!=='AbortError'&&mine===generation){message.textContent='Recorded review information could not load. Your observation text is retained.';}}finally{if(mine===generation)loading=false;}}
|
||||
function pause(enabled){const input=reader.querySelector('#reader-pause');if(enabled){pauseBefore=input.checked;input.checked=true;}else input.checked=pauseBefore;input.dispatchEvent(new Event('change'));}
|
||||
function showEditor(){if(reader.dataset.focus==='true'){const restore=reader.readerPreserveView?.();reader.querySelector('#reader-focus').click();restore?.();}const aside=root.closest('.writer3-reference');if(aside.hidden)document.querySelector('[data-writer-companion-toggle]')?.click();form.hidden=false;newButton.hidden=true;field('Observation').focus();}
|
||||
function begin(){if(busy)return;if(dirty){field('Observation').focus();return;}anchor=capture()||anchor;selected=anchor?.StartParagraph||null;wordReference(selected);void load();field('ID').value=crypto.randomUUID();field('Version').value='0';field('ContentVersion').value=reader.dataset.version;for(const n of['StartParagraph','EndParagraph','StartOffset','EndOffset'])field(n).value=anchor?.[n]??'';field('Observation').value='';field('Decision').value='';field('Status').value='Open';error.hidden=true;pause(true);dirty=true;reference.textContent=anchor?'Observation linked to the selected accepted paragraph(s).':'Chapter-level observation; no exact passage is claimed.';showEditor();}
|
||||
|
||||
14
PlotLine/wwwroot/js/writer2-workspaces.js
Normal file
14
PlotLine/wwwroot/js/writer2-workspaces.js
Normal file
@ -0,0 +1,14 @@
|
||||
(() => {
|
||||
'use strict';
|
||||
const opening=document.querySelector('[data-investigation-opening]');
|
||||
if(opening)fetch(opening.dataset.url,{cache:'no-store'}).then(async r=>{if(!r.ok)throw Error();opening.innerHTML=await r.text();}).catch(()=>{opening.querySelector('p').textContent='Starting concerns are temporarily unavailable. You can still open your saved investigations below.';});
|
||||
const discovery=document.querySelector('[data-discovery]');
|
||||
if(discovery){const key=`plotdirector.writerDiscovery.v1.${discovery.dataset.owner}.${discovery.dataset.project}.${discovery.dataset.book}`,tiles=discovery.querySelector('[data-discovery-tiles]');let preferences={};try{preferences=JSON.parse(localStorage.getItem(key))||{};}catch{}
|
||||
const message=discovery.querySelector('[data-discovery-message]');
|
||||
function render(){if(!tiles)return;let shown=0;for(const card of [...tiles.children].sort((a,b)=>Number(b.dataset.rank)-Number(a.dataset.rank)||a.dataset.tile.localeCompare(b.dataset.tile))){tiles.append(card);const value=preferences[card.dataset.tile],hidden=value==='dismissed'||Number(value)>Date.now();card.hidden=hidden||shown>=4;if(!card.hidden)shown++;}if(message)message.textContent=shown?'':'All suggestions are set aside. Reconsider them whenever you like.';}
|
||||
discovery.addEventListener('click',e=>{const card=e.target.closest('[data-tile]');if(card&&(e.target.matches('[data-dismiss]')||e.target.matches('[data-defer]'))){preferences[card.dataset.tile]=e.target.matches('[data-dismiss]')?'dismissed':Date.now()+7*86400000;try{localStorage.setItem(key,JSON.stringify(preferences));}catch{}render();discovery.querySelector('[data-reconsider]')?.focus();}if(e.target.matches('[data-reconsider]')){preferences={};try{localStorage.removeItem(key);}catch{}render();}});render();
|
||||
// Reuse the companion's authorised compact summary and native recommendation forms.
|
||||
window.addEventListener('plotdirector:guidance-summary',e=>{const area=discovery.querySelector('[data-discovery-active]');if(!area)return;area.replaceChildren();if(!e.detail?.active)return;const summary=e.detail.summary;if(String(summary.bookID)!==discovery.dataset.book)return;
|
||||
for(const finding of summary.findings.slice(0,2)){const available=finding.tools.filter(t=>t.available&&t.progress!=='Skipped'&&t.progress!=='Done').slice(0,2);for(const tool of available){const source=[...document.querySelectorAll('.pd-guidance-tool')].find(x=>x.dataset.capability===tool.id);const native=source?.querySelector('form');if(!native)continue;const article=document.createElement('article');article.className='writer2-tile';const h=document.createElement('h3');h.textContent=tool.name;const p=document.createElement('p');p.textContent='From your active investigation: '+finding.explanation;article.append(h,p,native.cloneNode(true));area.append(article);}}
|
||||
});}
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user