public void DoubleClickedBook() { if (_bookSelection.CurrentSelection.IsEditable && !_bookSelection.CurrentSelection.HasFatalError) { _editBookCommand.Raise(_bookSelection.CurrentSelection); } }
public void DoubleClickedBook() { // If we need the book to be checked out for editing, make sure it is. Do not allow double click // to check it out. if (_tcManager.CanEditBook()) { _editBookCommand.Raise(_bookSelection.CurrentSelection); } }
public void DoubleClickedBook() { // If we need the book to be checked out for editing, make sure it is. Do not allow double click // to check it out. if (_bookSelection.CurrentSelection?.IsSaveable ?? false) { _editBookCommand.Raise(_bookSelection.CurrentSelection); } }
public void RegisterWithApiHandler(BloomApiHandler apiHandler) { apiHandler.RegisterEndpointHandler(kAppUrlPrefix + "enabledExperimentalFeatures", request => { if (request.HttpMethod == HttpMethods.Get) { request.ReplyWithText(ExperimentalFeatures.TokensOfEnabledFeatures); } else // post { System.Diagnostics.Debug.Fail("We shouldn't ever be using the 'post' version."); request.PostSucceeded(); } }, false); apiHandler.RegisterEndpointHandler(kAppUrlPrefix + "autoUpdateSoftwareChoice", HandleAutoUpdate, false); /* It's not totally clear if these kinds of things fit well in this App api, or if we * will want to introduce a separate api for dealing with these kinds of things. I'm * erring on the side of less classes, code, for now, easy to split later.*/ apiHandler.RegisterEndpointLegacy(kAppUrlPrefix + "editSelectedBook", request => { _editBookCommand.Raise(_bookSelection.CurrentSelection); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointLegacy(kAppUrlPrefix + "makeFromSelectedBook", request => { // Original in LibraryBookView had this...not sure if we might want it again. //nb: don't move this to after the raise command, as the selection changes // var checkinNotice = string.Format("Created book from '{0}'", _bookSelection.CurrentSelection.TitleBestForUserDisplay); try { _createFromSourceBookCommand.Raise(_bookSelection.CurrentSelection); } catch (Exception error) { SIL.Reporting.ErrorReport.NotifyUserOfProblem(error, "Bloom could not add that book to the collection."); } request.PostSucceeded(); }, true); apiHandler.RegisterEndpointLegacy(kAppUrlPrefix + "selectedBookInfo", request => { // Requests the same information that is sent to the websocket // when the selection changes. request.ReplyWithJson(WorkspaceView.GetCurrentSelectedBookInfo()); }, true); }
private void _editBookButton_Click(object sender, EventArgs e) { _editBookCommand.Raise(_bookSelection.CurrentSelection); }
public void RegisterWithApiHandler(BloomApiHandler apiHandler) { apiHandler.RegisterEndpointHandler(kApiUrlPart + "list", HandleListRequest, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "name", request => { // always null? request.ReplyWithText(_collection.Name); request.ReplyWithText(_settings.CollectionName); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "books", HandleBooksRequest, false, false); apiHandler.RegisterEndpointHandler(kApiUrlPart + "book/thumbnail", HandleThumbnailRequest, false, false); // Note: the get part of this doesn't need to run on the UI thread, or even requiresSync. If it gets called a lot, consider // using different patterns for get and set so we can not use the uI thread for get. apiHandler.RegisterEndpointHandler(kApiUrlPart + "selected-book-id", request => { switch (request.HttpMethod) { case HttpMethods.Get: request.ReplyWithText("" + _collectionModel.GetSelectedBookOrNull()?.ID); break; case HttpMethods.Post: // We're selecting the book, make sure everything is up to date. // This first method does minimal processing to come up with the right collection and BookInfo object // without actually loading all the files. We need the title for the Performance Measurement and later // we'll use the BookInfo object to get the fully updated book. var newBookInfo = GetBookInfoFromPost(request); var titleString = newBookInfo.QuickTitleUserDisplay; using (PerformanceMeasurement.Global?.Measure("select book", titleString)) { // We could just put the PerformanceMeasurement in the CollectionModel.SelectBook() method, // but this GetUpdatedBookObjectFromBookInfo() actually does a non-trivial amount of work, // because it asks the CollectionModel to update the book files (including BringBookUpToDate). var book = GetUpdatedBookObjectFromBookInfo(newBookInfo); if (book.FolderPath != _bookSelection?.CurrentSelection?.FolderPath) { _collectionModel.SelectBook(book); } } request.PostSucceeded(); break; } }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "selectAndEditBook", request => { var book = GetBookObjectFromPost(request, true); if (book.FolderPath != _bookSelection?.CurrentSelection?.FolderPath) { _collectionModel.SelectBook(book); } if (GetCollectionOfRequest(request).Type == BookCollection.CollectionType.TheOneEditableCollection) { _editBookCommand.Raise(_bookSelection.CurrentSelection); } request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "duplicateBook/", (request) => { _collectionModel.DuplicateBook(GetBookObjectFromPost(request)); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "deleteBook/", (request) => { var collection = GetCollectionOfRequest(request); _collectionModel.DeleteBook(GetBookObjectFromPost(request), collection); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "collectionProps/", HandleCollectionProps, false, false); apiHandler.RegisterEndpointHandler(kApiUrlPart + "makeShellBooksBloompack/", (request) => { _collectionModel.MakeBloomPack(false); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "makeBloompack/", (request) => { _collectionModel.MakeReaderTemplateBloompack(); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "doChecksOfAllBooks/", (request) => { _collectionModel.DoChecksOfAllBooks(); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "rescueMissingImages/", (request) => { _collectionModel.RescueMissingImages(); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "doUpdatesOfAllBooks/", (request) => { _collectionModel.DoUpdatesOfAllBooks(); request.PostSucceeded(); }, true); }