Commit 59cc4f78 authored by Gatterdam Patrick's avatar Gatterdam Patrick
Browse files

Merge branch 'fix/backend-module' into 'master'

Fix/backend module

See merge request shopware/plugins/RicoDynamicFAQ!25
parents 35a1a120 aee04bc4
......@@ -3,7 +3,7 @@ module.exports = {
'root': true,
'env': {
'browser': true,
'jquery': true
'jquery': true,
},
'globals': {
'jQuery': true,
......@@ -13,19 +13,19 @@ module.exports = {
'Modernizr': true,
'Overlay': true,
'Shopware': true,
'Ext': true
'Ext': true,
},
'rules': {
'arrow-parens': 0,
'space-before-function-paren': 0,
'keyword-spacing': [
'warn'
'warn',
],
'padded-blocks': [
'warn'
'warn',
],
'space-in-parens': [
'warn'
'warn',
],
'generator-star-spacing': 0,
'no-shadow-restricted-names': 0,
......@@ -33,15 +33,14 @@ module.exports = {
'no-debugger': 0,
'semi': [
'error',
'always'
'always',
],
'one-var': 0,
'indent': [
'error',
4,
{ 'SwitchCase': 1 }
2,
{ 'SwitchCase': 1 },
],
'standard/no-callback-literal': 0
}
};
'standard/no-callback-literal': 0,
},
}
<?php
/**
* This file is part of the "RicoDynamicFaq" plugin for shopware.
* @package: RicoDynamicFaq
* @copyright: (c) 2019 Wolf Utz <utz@riconet.de>, Hees riconet GmbH
* @license: For the full copyright and license information,
* please read the LICENSE.txt file that was distributed with this source code.
*/
/**
* Class Shopware_Controllers_Backend_Faq.
*/
class Shopware_Controllers_Backend_FaqQuestionCategories extends Shopware_Controllers_Backend_Application
{
/**
* @var string
*/
protected $model = \RicoDynamicFaq\Models\Question::class;
/**
* @var string
*/
protected $alias = 'faq_question_category';
}
......@@ -30,6 +30,13 @@ class Category extends ModelEntity
*/
protected $id = 0;
/**
* @var bool
*
* @ORM\Column(type="boolean")
*/
protected $active = false;
/**
* @var string
*
......@@ -68,6 +75,22 @@ class Category extends ModelEntity
return $this->id;
}
/**
* @return bool
*/
public function isActive()
{
return $this->active;
}
/**
* @param bool $active
*/
public function setActive($active)
{
$this->active = $active;
}
/**
* @return string
*/
......
[de_DE]
view/category/detail/title=Kategorie
view/category/window/title=Kategorie
view/detail/category/title="Kategorie"
view/detail/question/question_title="Frage"
view/detail/question/answer_title="Antwort"
view/detail/window/title="Frage - Einzelansicht"
view/detail/window/alert_error_title = "Fehler"
view/detail/window/mail_error_message = "Es ist ein Fehler aufgetreten! Die E-Mail konnte nicht versendet werden."
view/detail/window/alert_success_title = "Erfolg"
view/detail/window/mail_success_message = "Die E-Mail wurde erfolgreich gesendet."
view/main/window/title=FAQ
view/tab/category/title=Kategorie
view/tab/question/title=Frage
view/tab/question/question_title=Frage
view/tab/question/clicks_title=Klicks
view/tab/question/score_title=Wertung
view/tab/question/user_email=Email
view/tab/question/active_title=Aktiv
[en_GB]
view/category/detail/title=Category
view/category/window/title=Category
view/detail/category/title="Category"
view/detail/question/question_title="Question"
view/detail/question/answer_title="Answer"
view/detail/window/title="Question - detail"
view/detail/window/alert_error_title = "Error"
view/detail/window/mail_error_message = "An error occurred! The email has not been send."
view/detail/window/alert_success_title = "Success"
view/detail/window/mail_success_message = "The email has been send successfully."
view/main/window/title=FAQ
view/tab/category/title=Category
view/tab/question/title=Question
view/tab/question/question_title=Question
view/tab/question/clicks_title=Clicks
view/tab/question/score_title=Score
view/tab/question/user_email=Email
view/tab/question/active_title=Active
[default]
main_window/title = "FAQ"
[de_DE : default]
main_window/title = "FAQ"
\ No newline at end of file
[default]
grid/title = "Categories"
detail_window/title = "Category details"
[de_DE : default]
grid/title = "Kategorien"
detail_window/title = "Kategorie Details"
[default]
grid/title = "Questions"
detail_window/title = "Question details"
detail_window/button/mail_user = "Mail questioner"
detail_window/send_mail_alert/title/success = "Success"
detail_window/send_mail_alert/title/error = "Error"
detail_window/send_mail_alert/message/success = "Mail has been successfully sent!"
detail_window/send_mail_alert/message/error = "Could not send email! Please check the logs for more information."
detail/field_sets/title/tracking = "Tracking"
detail/field_sets/title/content = "Content"
category_association_grid/title = "Linked categories"
[de_DE : default]
grid/title = "Fragen"
detail_window/title = "Question Details"
detail_window/button/mail_user = "Fragensteller informieren"
detail_window/send_mail_alert/title/success = "Erfolg"
detail_window/send_mail_alert/title/error = "Fehler"
detail_window/send_mail_alert/message/success = "Die E-Mail wurde erfolgreich versendet!"
detail_window/send_mail_alert/message/error = "Die E-mail konnte nicht gesendet werden! Bitte überprüfen Sie den Log für weitere Informationen."
detail/field_sets/title/tracking = "Tracking"
detail/field_sets/title/content = "Inhalt"
category_association_grid/title = "Verknüpfte Kategorien"
\ No newline at end of file
Ext.define('Shopware.apps.Faq', {
extend: 'Enlight.app.SubApplication',
name: 'Shopware.apps.Faq',
loadPath: '{url action=load}',
bulkLoad: true,
controllers: ['Main'],
views: [
'main.Window',
'tab.Category',
'tab.Question',
'detail.Window',
'detail.Question',
'detail.Category',
'category.Window',
'category.Detail'
],
models: ['Question', 'Category', 'QuestionCategory'],
stores: ['Question', 'Category'],
launch: function () {
return this.getController('Main').mainWindow;
}
extend: 'Enlight.app.SubApplication',
name: 'Shopware.apps.Faq',
loadPath: '{url action=load}',
bulkLoad: true,
controllers: ['Main'],
views: [
'MainWindow',
'category.Grid',
'category.DetailWindow',
'category.Detail',
'question.Grid',
'question.DetailWindow',
'question.Detail',
'question.CategoryAssociationGrid'
],
models: ['Category', 'Question', 'QuestionCategory'],
stores: ['Category', 'Question'],
launch: function () {
return this.getController('Main').mainWindow;
}
});
Ext.define('Shopware.apps.Faq.controller.Main', {
extend: 'Enlight.app.Controller',
init: function () {
var me = this;
me.handleStore(me);
me.mainWindow = me.getView('main.Window').create({
questionStore: me.subApplication.questionStore,
categoryStore: me.subApplication.categoryStore
}).show();
},
handleStore: function(me) {
me.subApplication.categoryStore = me.subApplication.getStore('Category');
me.subApplication.questionStore = me.subApplication.getStore('Question');
me.subApplication.categoryStore.load();
me.subApplication.questionStore.load();
}
extend: 'Enlight.app.Controller',
init: function () {
var me = this;
me.loadStores(me);
me.mainWindow = me.getView('MainWindow').create({
questionStore: me.subApplication.questionStore,
categoryStore: me.subApplication.categoryStore
}).show();
},
loadStores: function (me) {
me.setStores(me);
me.subApplication.categoryStore.load();
me.subApplication.questionStore.load();
},
setStores: function (me) {
me.subApplication.categoryStore = me.subApplication.getStore('Category');
me.subApplication.questionStore = me.subApplication.getStore('Question');
}
});
Ext.define('Shopware.apps.Faq.model.Category', {
extend: 'Shopware.data.Model',
configure: function () {
return {
controller: 'FaqCategory',
related: 'Shopware.apps.Faq.view.category.Detail'
};
},
fields: [
{ name: 'id', type: 'int', useNull: true },
{ name: 'name', type: 'string', useNull: true }
]
extend: 'Shopware.data.Model',
fields: [
{ name: 'id', type: 'int', useNull: true },
{ name: 'active', type: 'boolean' },
{ name: 'name', type: 'string' }
],
configure: function () {
return {
controller: 'FaqCategory',
detail: 'Shopware.apps.Faq.view.category.Detail'
};
}
});
Ext.define('Shopware.apps.Faq.model.Question', {
extend: 'Shopware.data.Model',
configure: function () {
return {
controller: 'Faq',
detail: 'Shopware.apps.Faq.view.detail.Question'
};
},
fields: [
{ name: 'id', type: 'int', useNull: true },
{ name: 'questionText', type: 'string' },
{ name: 'answerText', type: 'string' },
{ name: 'clicks', type: 'int' },
{ name: 'score', type: 'int' },
{ name: 'websiteUserCreated', type: 'boolean' },
{ name: 'websiteUserEmail', type: 'string' },
{ name: 'active', type: 'boolean' }
],
associations: [
{
relation: 'ManyToMany',
type: 'hasMany',
model: 'Shopware.apps.Faq.model.QuestionCategory',
name: 'getCategories',
associationKey: 'categories'
}
]
extend: 'Shopware.data.Model',
fields: [
{ name: 'id', type: 'int', useNull: true },
{ name: 'active', type: 'boolean' },
{ name: 'questionText', type: 'string' },
{ name: 'answerText', type: 'string' },
{ name: 'clicks', type: 'int' },
{ name: 'score', type: 'int' },
{ name: 'websiteUserCreated', type: 'boolean' },
{ name: 'websiteUserEmail', type: 'string' }
],
associations: [
{
relation: 'ManyToMany',
type: 'hasMany',
model: 'Shopware.apps.Faq.model.QuestionCategory',
name: 'getCategories',
associationKey: 'categories'
}
],
configure: function () {
return {
controller: 'Faq',
detail: 'Shopware.apps.Faq.view.question.Detail'
};
}
});
Ext.define('Shopware.apps.Faq.model.QuestionCategory', {
extend: 'Shopware.data.Model',
configure: function() {
return {
related: 'Shopware.apps.Faq.view.detail.Category'
};
},
fields: [
{ name: 'id', type: 'int', useNull: true },
{ name: 'name', type: 'string', useNull: true }
]
extend: 'Shopware.data.Model',
fields: [
{ name: 'id', type: 'int', useNull: true },
{ name: 'active', type: 'boolean' },
{ name: 'name', type: 'string' }
],
configure: function () {
return {
related: 'Shopware.apps.Faq.view.question.CategoryAssociationGrid'
};
}
});
Ext.define('Shopware.apps.Faq.store.Category', {
extend: 'Shopware.store.Listing',
configure: function () {
return {
controller: 'FaqCategory'
};
},
model: 'Shopware.apps.Faq.model.Category'
extend: 'Shopware.store.Listing',
model: 'Shopware.apps.Faq.model.Category',
configure: function () {
return {
controller: 'FaqCategory'
};
}
});
Ext.define('Shopware.apps.Faq.store.Question', {
extend: 'Shopware.store.Listing',
configure: function () {
return {
controller: 'Faq'
};
},
model: 'Shopware.apps.Faq.model.Question'
extend: 'Shopware.store.Listing',
model: 'Shopware.apps.Faq.model.Question',
configure: function () {
return {
controller: 'Faq'
};
}
});
// {namespace name="backend/faq/view/category/detail"}
Ext.define('Shopware.apps.Faq.view.category.Detail', {
extend: 'Shopware.grid.Association',
alias: 'widget.faq-category-detail',
height: 100,
title: '{s name=title}{/s}',
initComponent: function () {
var me = this;
if (me.plugins === undefined) {
me.plugins = [];
}
me.plugins.push({
pluginId: 'translation',
ptype: 'translation',
translationType: 'faq_category'
});
me.callParent(arguments);
},
// region sw_bug-workaround
/**
* workaround for shopware bug
*/
getForm: function () {
return this;
},
/**
* workaround for shopware bug
*/
getRecord: function () {
return this.record;
},
/**
* workaround for shopware bug
*/
getFields: function() {
var me = this;
return {
items: [
me.down('[name=name]')
]
};
},
// endregion
configure: function () {
return {
controller: 'CategoryFaq',
columns: {
name: { translatable: true, translationName: 'name' }
extend: 'Shopware.model.Container',
alias: 'widget.faq-category-detail-container',
padding: 20,
configure: function () {
return {
controller: 'FaqCategory',
fieldSets: [
{
title: '',
fields: {
active: {}
}
},
{
title: '',
fields: {
name: {
translatable: true
}
};
}
}
}
]
};
}
});
// {namespace name=backend/faq/view/category}
Ext.define('Shopware.apps.Faq.view.category.DetailWindow', {
extend: 'Shopware.window.Detail',
alias: 'widget.faq-category-detail-window',
title: '{s name=detail_window/title}{/s}',
height: 450,
configure: function () {
return {
translationKey: 'faq_category'
};
}
});
// {namespace name=backend/faq/view/category}
Ext.define('Shopware.apps.Faq.view.category.Grid', {
extend: 'Shopware.grid.Panel',
alias: 'widget.faq-category-listing-grid',
region: 'center',
title: '{s name=grid/title}{/s}',
configure: function () {
return {
detailWindow: 'Shopware.apps.Faq.view.category.DetailWindow'
};
}
});
// {namespace name="backend/faq/view/category/window"}
Ext.define('Shopware.apps.Faq.view.category.Window', {
extend: 'Shopware.window.Detail',
alias: 'widget.faq-question-detail-window',
title: '{s name=title}{/s}',
height: 720,
width: 650,
configure: function() {
return {
associations: [ 'categories' ]
};
},
createToolbarItems: function () {
var me = this;
var items = me.callParent(arguments);
if (me.record.data.websiteUserCreated) {
items.push(me.createToolbarButton());
}
return items;
},
createToolbarButton: function () {
var me = this;
return Ext.create('Ext.button.Button', {
cls: 'primary',
name: 'detail-mail-button',
text: 'Mail User',
handler: function () {
me.sendEmailAjax();
}
});
}
});
// {namespace name="backend/faq/view/detail/category"}
Ext.define('Shopware.apps.Faq.view.detail.Category', {
extend: 'Shopware.grid.Association',
alias: 'widget.faq-question-detail-category',
height: 300,
title: '{s name="title"}{/s}',
configure: function() {
return {
controller: 'FaqQuestionCategories',
columns: {
name: {}
}
};
}
});
// {namespace name="backend/faq/view/detail/question"}
Ext.define('Shopware.apps.Faq.view.detail.Question', {
extend: 'Shopware.model.Container',
alias: 'widget.faq-question-detail-container',