One Hat Cyber Team
  • Dir : ~/usr/local/psa/admin/cp/public/javascript/app/
  • View File Name : aha.js.map
    ' +\n '
    ' +\n '
    ' +\n `
    ${this.lmsg('voteBetterHint')}
    ` +\n '
    ' +\n '
    ' +\n '' +\n '' +\n '' +\n ''\n ),\n buttons: [{\n title: this.lmsg('voteButtonOk'),\n id: 'aha-vote-button-ok',\n class: 'action',\n handler: this.handleVoteButton.bind(this),\n }, {\n title: Locale.getSection('components.buttons').lmsg('cancel'),\n id: 'aha-vote-button-cancel',\n handler(event, popup) {\n popup.hide();\n },\n }],\n ...config,\n });\n }\n\n _initComponentElement() {\n super._initComponentElement();\n\n render(this._componentElement.querySelector('#aha-rating'), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(i => (\n createElement('label', {\n class: `nps-survey__score nps-survey__score--${i}`,\n onclick: this.checkPossibleSendVote.bind(this),\n }, [\n createElement('input', { type: 'radio', name: 'nps-survey-option', value: i }),\n createElement('span', { class: 'nps-survey__score-label' }),\n ])\n )));\n }\n\n hide() {\n super.hide();\n\n if (this.voted) {\n return;\n }\n\n if (this.checkPossibleSendVote() || this.getFeedbackGood() || this.getFeedbackBetter()) {\n this.sendVote();\n } else {\n this.sendHide();\n }\n }\n\n handleVoteButton() {\n if (!this.checkPossibleSendVote()) {\n return;\n }\n\n this.voted = true;\n this.sendVote();\n this.hide();\n\n new ThankDialog();\n }\n\n checkPossibleSendVote() {\n const survey = this._componentElement.querySelector('.nps-survey');\n const rate = this.getRate();\n\n if (rate) {\n survey.classList.remove('error');\n const errorField = survey.querySelector('.field-errors');\n if (errorField) {\n errorField.parentNode.removeChild(errorField);\n }\n } else {\n survey.classList.add('error');\n const errorField = survey.querySelector('.field-errors');\n if (!errorField) {\n render(survey, (\n '' +\n `${this.lmsg('voteRequire')}` +\n ''\n ));\n }\n }\n\n return rate;\n }\n\n sendVote() {\n api.post(prepareUrl('/admin/aha/vote'), {\n voted: this.voted || false,\n rate: this.getRate(),\n feedbackGood: this.getFeedbackGood(),\n feedbackBetter: this.getFeedbackBetter(),\n dialogAtPage: window.location.pathname,\n });\n }\n\n sendHide() {\n api.post(prepareUrl('/admin/aha/hide'));\n }\n\n getRate() {\n const checked = this._componentElement.querySelector(`#${this.getId()}-form input[name=nps-survey-option]:checked`);\n return checked ? checked.value : '';\n }\n\n getFeedbackGood() {\n return this._componentElement.querySelector('#aha-good').value.trim();\n }\n\n getFeedbackBetter() {\n return this._componentElement.querySelector('#aha-better').value.trim();\n }\n}\n\nclass ThankDialog extends Popup {\n _initConfiguration(config) {\n this.setLocale(Locale.getSection('components.aha'));\n\n const buttons = [{\n title: this.lmsg('thankButtonClose'),\n class: 'action',\n handler(event, popup) {\n popup.hide();\n },\n }];\n\n const content = `

    ${this.lmsg('thankHint')}

    `;\n\n super._initConfiguration({\n id: 'thank-dialog',\n title: this.lmsg('thankTitle'),\n closeButtonEnabled: true,\n hideOnEscape: true,\n content,\n buttons,\n ...config,\n });\n }\n}\n\nexport default props => new AhaDialog(props);\n"],"names":["AhaDialog","Popup","_initConfiguration","config","this","setLocale","Locale","getSection","super","id","title","lmsg","closeButtonEnabled","hideOnEscape","content","buttons","class","handler","handleVoteButton","bind","event","popup","hide","_initComponentElement","render","_componentElement","querySelector","map","i","createElement","onclick","checkPossibleSendVote","type","name","value","voted","getFeedbackGood","getFeedbackBetter","sendVote","sendHide","ThankDialog","survey","rate","getRate","classList","remove","errorField","parentNode","removeChild","add","api","post","prepareUrl","feedbackGood","feedbackBetter","dialogAtPage","window","location","pathname","checked","getId","trim","props"],"sourceRoot":""}