/*
* MathGraph32 Javascript : Software for animating online dynamic mathematics figures
* https://www.mathgraph32.org/
* @Author Yves Biton (yves.biton@sesamath.net)
* @License: GNU AGPLv3 https://www.gnu.org/licenses/agpl-3.0.html
*/
import { ce, ceIn } from 'src/kernel/dom'
import { getStr } from '../kernel/kernel'
import MtgDlg from './MtgDlg'
import $ from 'jquery'
export default ChoixFinNumDlg
/**
* Dialogue de choix des objets finaux numériques pour une construction
* @param {MtgApp} app mtgApp propriétaire
* @constructor
*/
function ChoixFinNumDlg (app) {
MtgDlg.call(this, app, 'ChoixFinNumDlg')
this.inf = app.listePr.listObjFinDisp(app)
const tabPrincipal = ce('table')
this.appendChild(tabPrincipal)
let tr = ceIn(tabPrincipal, 'tr')
const label = ceIn(tr, 'label')
$(label).html(getStr('FinDlg1'))
tr = ceIn(tabPrincipal, 'tr')
this.select = ceIn(tr, 'select', {
size: 12, // Le nombre de lignes visibles par défaut
multiple: 'multiple', // Sélection multiple possible pour cette liste
style: 'width:300px'
})
tr = ceIn(tabPrincipal, 'tr')
const label2 = ceIn(tr, 'label')
$(label2).html(getStr('FinDlg2'))
// C'est là qu'on ajoute les noms des valeurs numériques disponibles dans la liste déroulante
for (let i = 0; i < this.inf.noms.length; i++) {
const option = ceIn(this.select, 'Option', {
class: 'mtgOption'
})
if (app.listeFinNG.contains(this.inf.pointeurs[i])) option.setAttribute('selected', 'selected')
$(option).html(this.inf.noms[i])
}
this.create('ChoixFinNumConst', 400)
}
ChoixFinNumDlg.prototype = new MtgDlg()
ChoixFinNumDlg.prototype.OK = function () {
const listNG = this.app.listeFinNG
listNG.retireTout()
const options = this.select.options
for (let i = 0; i < options.length; i++) {
if ($(options[i]).prop('selected')) listNG.add(this.inf.pointeurs[i])
}
this.destroy()
this.app.activeOutilCapt()
}