Skip to content

Commit

Permalink
Define selected record by default after deletion of one record from t…
Browse files Browse the repository at this point in the history
…he stage (#403)

* once you remove one record, the system will select by default the new selected record.When you have 2 records displayed, and you remove one from the stage , the other one will become the selected record by default

* remove alerts

* downgrade werkzeug - see notes

Co-authored-by: Eric Attere <[email protected]>
Co-authored-by: Aaron Helton <[email protected]>
  • Loading branch information
3 people committed Apr 5, 2022
1 parent 180a0d5 commit 7a8a913
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
47 changes: 43 additions & 4 deletions dlx_rest/static/js/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export let multiplemarcrecordcomponent = {
collectionRecord2:"",
isRecordOneDisplayed: false,
isRecordTwoDisplayed: false,
displayedJmarcObject:[],
listElemToCopy:[],
elementToCopy:{
collection:"",
Expand Down Expand Up @@ -163,6 +164,28 @@ export let multiplemarcrecordcomponent = {
recup=this
},
methods: {

// add a new jmarc object in the array of Marc objects
addJmarcTodisplayedJmarcObject(jmarcToAdd){
if ((this.displayedJmarcObject.length===0) || (this.displayedJmarcObject.length===1)){
this.displayedJmarcObject.push(jmarcToAdd)
}
}

,

// remove a jmarc object from the array of Marc objects
removeJmarcTodisplayedJmarcObject(recordId){
let indexToDelete
for (let index = 0; index < this.displayedJmarcObject.length; index++) {
if (recordId===this.displayedJmarcObject[index].recordId){
indexToDelete=index
}
}
this.displayedJmarcObject.splice(indexToDelete,1)
}
,

////////////////////////////////////////////////////////
///// definition of the methods used in the listeners
////////////////////////////////////////////////////////
Expand Down Expand Up @@ -611,10 +634,6 @@ export let multiplemarcrecordcomponent = {
this.listElemToCopy=[]
},

pasteItems(record1,record2){

},

clearSelectedRecord(){

// remove checked option
Expand Down Expand Up @@ -712,15 +731,18 @@ export let multiplemarcrecordcomponent = {

if (divID === "record1") {
// reset the parameters
this.removeJmarcTodisplayedJmarcObject(this.record1)
this.$root.$refs.basketcomponent.removeRecordFromRecordDisplayed(this.record1)
this.record1 = ""
this.isRecordOneDisplayed = false
this.collectionRecord1=""
let recup=document.getElementById("record1")
recup.innerHTML=""
this.callChangeStyling("Record removed from the editor", "row alert alert-success")

}
else if (divID === "record2") {
this.removeJmarcTodisplayedJmarcObject(this.record2)
this.$root.$refs.basketcomponent.removeRecordFromRecordDisplayed(this.record2)
this.record2 = ""
this.isRecordTwoDisplayed = false
Expand All @@ -733,6 +755,18 @@ export let multiplemarcrecordcomponent = {
this.selectedRecord=""
this.optimizeEditorDisplay(this.targetedTable)
this.targetedTable=""

// check if we still have a record displayed
if (this.displayedJmarcObject.length>0) {

//alert("the record always displayed is " + this.displayedJmarcObject[0].recordId)
//alert("the record size is " + this.displayedJmarcObject.length)
this.selectRecord(this.displayedJmarcObject[0])
this.selectedRecord = this.displayedJmarcObject[0].recordId
this.selectedDiv=this.displayedJmarcObject[0].recordId

}

},
displayMarcRecord(jmarc, readOnly) {
// Add to div
Expand All @@ -759,6 +793,11 @@ export let multiplemarcrecordcomponent = {
jmarc.div.appendChild(table);
this.selectRecord(jmarc)

// add the jmarc inside the list of jmarc objects displayed
// only if the array size is under 2

this.addJmarcTodisplayedJmarcObject(jmarc)

//////////////////////////////////////////////////////////////////////////////
// optimize the display just when you have one record displayed
//////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ pymongo
pytest
python-ulid
troposphere
# flask-restx isn't yet compatible with werkzeug 2.1+
werkzeug < 2.1

0 comments on commit 7a8a913

Please sign in to comment.