Skip to content

Commit

Permalink
fix: add window features to entity form popup
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmacdonald committed Aug 28, 2018
1 parent 10bd803 commit 32e288f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if (BroadcastChannel.default !== undefined) {
}
let channel
let entityFormWindow
let entityFormWindowOptions = 'menubar=no,statusbar=no,toolbar=no'

// custom styles
let styleEl = document.createElement('style')
Expand Down Expand Up @@ -325,12 +326,12 @@ function initializeEntityPopup() {
})

$('#cwrc-entity-lookup-new').click(function(event) {
entityFormWindow = window.open(entityFormsRoot+currentSearchOptions.entityType)
openEntityFormWindow(false)
})

$('#cwrc-entity-lookup-edit').click(function(event) {
if (selectedResult !== undefined && selectedResult.repository === 'CWRC') {
entityFormWindow = window.open(entityFormsRoot+currentSearchOptions.entityType+'?entityId='+selectedResult.id)
openEntityFormWindow(true)
}
})

Expand Down Expand Up @@ -370,6 +371,18 @@ function initializeEntityPopup() {
}
}

function openEntityFormWindow(isEdit) {
let url = entityFormsRoot + currentSearchOptions.entityType
if (isEdit) {
url += '?entityId=' + selectedResult.id
}
let width = Math.min(1100, window.outerWidth * 0.8)
let height = window.outerHeight * 0.8
let top = (window.outerHeight - height) * 0.5
let left = (window.outerWidth - width) * 0.5
entityFormWindow = window.open(url, 'entityFormWindow', entityFormWindowOptions+',width='+width+',height='+height+',top='+top+',left='+left)
}

function handleSelectButtonState() {
let disable = true
if (selectedResult !== undefined) {
Expand Down

0 comments on commit 32e288f

Please sign in to comment.