# HG changeset patch # User Zoe Hong # Date 1427729027 -7200 # Node ID 5cf9720a2e25a73875b8f32436fb976436f3478a # Parent 95f929d7b318ca845834c46ba59e9213b0c70e77 New: add reloadText to load the latest version diff -r 95f929d7b318 -r 5cf9720a2e25 controllers/extractapp.php --- a/controllers/extractapp.php Mon Mar 30 15:54:04 2015 +0200 +++ b/controllers/extractapp.php Mon Mar 30 17:23:47 2015 +0200 @@ -27,7 +27,6 @@ $viewmodel->GetInfoFromPreviousPage($this->postdata); $response = $viewmodel->SaveFullTextToLGService($this->postdata); $viewmodel->UpdateInfoByResponseFromLGService($response); // update file_id, branch_id, user_id - // TODO: GetTextFromFileId?? reload saved file from LGService, necessary! $viewmodel->GetTextFromFileId(); $this->ReturnView($viewmodel->StartTagging(), true); break; @@ -38,8 +37,12 @@ case 'SmartRegexSave': $viewmodel->SmartRegexSave($this->postdata); break; - case 'Reload': - // $viewmodel->Reload(); + case 'ReloadText': + $viewmodel->messages .= "Reload the latest text "."
"; + $viewmodel->GetInfoFromPreviousPage($this->postdata); + $viewmodel->ReloadSetting(); // set file_id = current_fileId, current_fileId = 0 + $viewmodel->GetTextFromFileId(); + $this->ReturnView($viewmodel->StartTagging(), true); break; case 'ContinueTagging': diff -r 95f929d7b318 -r 5cf9720a2e25 models/extractapp.php --- a/models/extractapp.php Mon Mar 30 15:54:04 2015 +0200 +++ b/models/extractapp.php Mon Mar 30 17:23:47 2015 +0200 @@ -348,13 +348,15 @@ $status = (string)$response["status"]; if ($status == "ok") { - $this->messages .= "saving success."; + $this->messages .= "Saving success."; $this->file_id = (string)$response_file["id"]; $this->branch_id = (string)$response_branch["id"]; } else if ($status == "error") { // saving not success - $this->messages .= "saving does not success! ".(string)$response["message"]; + $this->messages .= "Saving Failed! ".(string)$response["message"]."
"; + $this->messages .= "Please check branch ".$this->branch_id." in LGService, and modify from the latest version.
"; + $response_currentFile = $response["currentFile"]; //$this->current_fileId = $response["currentFileId"]; $this->current_fileId = (string)$response_currentFile["id"]; @@ -363,6 +365,14 @@ } + + public function ReloadSetting() { + if ($this->current_fileId != 0) { + $this->file_id = $this->current_fileId; + $this->current_fileId = 0; + } + } + private function AppendMetaData($text_content) { $text = ''; $text .= "\n\n"; diff -r 95f929d7b318 -r 5cf9720a2e25 views/Extractapp/TaggingText.php --- a/views/Extractapp/TaggingText.php Mon Mar 30 15:54:04 2015 +0200 +++ b/views/Extractapp/TaggingText.php Mon Mar 30 17:23:47 2015 +0200 @@ -79,6 +79,34 @@ } } +function reloadText() { + // confirm to reload + var r = confirm("Your editing will be discarded. Are you sure you want to reload?"); + if (r != true) { + return; + } + + var form = document.createElement("form"); + form.setAttribute("method", "post"); + form.setAttribute("action", "./TaggingText"); // hand to controller + //form.setAttribute("target", "_self"); + form.setAttribute("target", "_blank"); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "topic"); + var topic_id = JSON.parse(''); + hiddenField.setAttribute("value", topic_id); + form.appendChild(hiddenField); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "func"); + hiddenField.setAttribute("value", "ReloadText"); + form.appendChild(hiddenField); + + _postForContineTagging(form); + +} + // TODO: Popup to proceeding the saving situations function handleFileVersionConflict() { var info = JSON.parse(''); @@ -86,74 +114,8 @@ if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ // -- there might be conflicts between different version - alert("Someone edited this file and saved before you."); + alert("Your saving failed! Someone edited this file and saved before you."); return; - - var retVal = confirm('There were something happened/someone editing in the between of time.\nDo you want to force saving? (There might be conflicts between two versions.)'); - if( retVal == true ){ - // TODO: force saving with currentFileId - alert("You do the force saving!"); - //saveTextToLGService(); - - }else{ - var loadLastest = confirm("Do you want to reload for the lastest version? (Your current editing will lost.)"); - - console.log("loadLastest="+loadLastest); - /* - var form = document.createElement("form"); - form.setAttribute("method", "post"); - form.setAttribute("action", "./TaggingText"); // hand to controller - form.setAttribute("target", "_blank"); - - var topic_id = JSON.parse(''); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "topic"); - hiddenField.setAttribute("value", topic_id); - form.appendChild(hiddenField); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "func"); - hiddenField.setAttribute("value", "Reload"); // reload - form.appendChild(hiddenField); - - _postForContineTagging(form); - - alert("You will reload the latest version."); - */ - /* - if (loadLastest == true) { - // TODO: reload page with the currentFileId - console.log('loadLastest is true'); - $.ajax({ - type : 'POST', - url : './TaggingText', - async : false, - data : 'func=Reload', - success: function (result) { - //var lastest_editing = jQuery.parseJSON(result); - console.log("lastest_editing string:"+result); - // change text to the new one - //var el = document.getElementById("editable-area"); - //el.innerHTML = lastest_editing; - //alert("Reload the page!"); - }, - error: function (result) { - alert("Reload Fails!"); - } - }).done(function(result) { - // reload page - //document.location.reload(true); - - }); - - } else { - alert("Just a reminder, there is a new version for this branch."); - } - */ - - } - } return; @@ -516,9 +478,6 @@ */ } - - - function exportAll(topic_id) { var el = document.getElementById("editable-area"); var str= "" + el.innerHTML; @@ -579,7 +538,6 @@ } // =========== - function tagwithOnlytag( range, stringSelection, tag ) { saveUndoText(); var topic_tag = JSON.parse(''); @@ -625,9 +583,6 @@ $('.tagItemDivClass').remove(); } - - - function replaceSmartRegex() { saveUndoText(); var startPage = $('#regexPageStart2').val(); @@ -665,8 +620,6 @@ //document.styleSheets[0].addRule("tag001", "color:green;") } - - function saveTextToLGService() { // ------------- @@ -774,8 +727,6 @@ */ } - - function chooseTopic(default_topic_id) { var t = JSON.parse( '' ); var info = JSON.parse(''); @@ -875,7 +826,6 @@ var info = JSON.parse( ''); if (info) { - // TODO: different field info array based on fileId(branchId) existing or not if (info['file_id']) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("name", "fileId"); @@ -961,7 +911,6 @@ } - $(document).on("change", '#smartRegexPopUpSelectWord', function (e) {
+ +
+
Config Topic:
current topic is - +