Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
voting.typo3.org
extensions
election
Commits
43cc9f45
Commit
43cc9f45
authored
Dec 22, 2015
by
Oliver Eglseder
Browse files
[TASK] Add ElectionCircular preview
parent
fbbeab1d
Changes
22
Hide whitespace changes
Inline
Side-by-side
Classes/Controller/BeDashboardController.php
View file @
43cc9f45
<?php
namespace
TYPO3\Election\Controller
;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use
TYPO3\Election\Domain\Repository\ElectionCircularRepository
;
use
TYPO3\Election\Domain\Repository\ElectorImportRepository
;
/**
...
...
@@ -40,7 +41,14 @@ class BeDashboardController extends AbstractBeController
]
);
if
(
$this
->
backendUserHasUserGroup
(
$this
->
configuration
->
getElectionManagerGroup
()))
{
$this
->
view
->
assign
(
'electorImports'
,
$this
->
objectManager
->
get
(
ElectorImportRepository
::
class
)
->
findAll
());
$this
->
view
->
assign
(
'electorImports'
,
$this
->
objectManager
->
get
(
ElectorImportRepository
::
class
)
->
findAll
()
);
$this
->
view
->
assign
(
'electionCirculars'
,
$this
->
objectManager
->
get
(
ElectionCircularRepository
::
class
)
->
findAll
()
);
}
}
...
...
Classes/Controller/BeElectionCircularController.php
View file @
43cc9f45
<?php
namespace
TYPO3\Election\Controller
;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use
TYPO3\Election\Domain\Model\ElectionCircular
;
/**
* Class BeConfigurationController
...
...
@@ -21,6 +22,12 @@ class BeElectionCircularController extends AbstractProtectedBeController
{
const
CONTROLLER_NAME
=
'BeElectionCircular'
;
const
ACTION_LIST
=
'list'
;
const
ACTION_NEW
=
'new'
;
const
ACTION_CREATE
=
'create'
;
const
ACTION_EDIT
=
'edit'
;
const
ACTION_UPDATE
=
'update'
;
const
ACTION_DELETE
=
'delete'
;
const
ACTION_SEND
=
'send'
;
/**
* @var \TYPO3\Election\Domain\Repository\ElectionCircularRepository
...
...
@@ -28,6 +35,12 @@ class BeElectionCircularController extends AbstractProtectedBeController
*/
protected
$electionCircularRepository
=
null
;
/**
* @var \TYPO3\Election\Domain\Repository\ElectionRepository
* @inject
*/
protected
$electionRepository
=
null
;
/**
*
*/
...
...
@@ -36,6 +49,59 @@ class BeElectionCircularController extends AbstractProtectedBeController
$this
->
view
->
assign
(
'electionCirculars'
,
$this
->
electionCircularRepository
->
findAll
());
}
/**
*
*/
public
function
newAction
()
{
$this
->
view
->
assign
(
'electionCircular'
,
$this
->
objectManager
->
get
(
ElectionCircular
::
class
));
$this
->
view
->
assign
(
'elections'
,
$this
->
electionRepository
->
findAll
());
}
/**
* @param ElectionCircular $electionCircular
*/
public
function
createAction
(
ElectionCircular
$electionCircular
)
{
$this
->
electionCircularRepository
->
add
(
$electionCircular
);
$this
->
redirect
(
self
::
ACTION_LIST
);
}
/**
* @param ElectionCircular $electionCircular
*/
public
function
editAction
(
ElectionCircular
$electionCircular
)
{
$this
->
view
->
assign
(
'electionCircular'
,
$electionCircular
);
$this
->
view
->
assign
(
'elections'
,
$this
->
electionRepository
->
findAll
());
}
/**
* @param ElectionCircular $electionCircular
*/
public
function
updateAction
(
ElectionCircular
$electionCircular
)
{
$this
->
electionCircularRepository
->
update
(
$electionCircular
);
$this
->
redirect
(
self
::
ACTION_LIST
);
}
/**
* @param ElectionCircular $electionCircular
*/
public
function
deleteAction
(
ElectionCircular
$electionCircular
)
{
$this
->
electionCircularRepository
->
remove
(
$electionCircular
);
$this
->
redirect
(
self
::
ACTION_LIST
);
}
/**
* @param ElectionCircular $electionCircular
*/
public
function
sendAction
(
ElectionCircular
$electionCircular
)
{
$this
->
view
->
assign
(
'electionCircular'
,
$electionCircular
);
}
/**
* @return string
*/
...
...
@@ -45,6 +111,12 @@ class BeElectionCircularController extends AbstractProtectedBeController
','
,
[
self
::
ACTION_LIST
,
self
::
ACTION_NEW
,
self
::
ACTION_CREATE
,
self
::
ACTION_EDIT
,
self
::
ACTION_UPDATE
,
self
::
ACTION_DELETE
,
self
::
ACTION_SEND
,
]
);
}
...
...
Classes/Domain/Model/AbstractPerson.php
View file @
43cc9f45
...
...
@@ -157,4 +157,12 @@ class AbstractPerson extends AbstractEntity
),
];
}
/**
* @return string
*/
public
function
getSalutation
()
{
return
LocalizationUtility
::
translate
(
'model.abstract_person.salutation.'
.
$this
->
gender
,
'election'
);
}
}
Classes/Domain/Model/ElectionCircular.php
View file @
43cc9f45
...
...
@@ -81,4 +81,55 @@ class ElectionCircular extends AbstractEntity
{
$this
->
election
=
$election
;
}
/**
*
*/
public
function
getDummyBody
()
{
$elector
=
new
Elector
();
$elector
->
setFirstName
(
'Kasper'
);
$elector
->
setLastName
(
'Skårhøj'
);
$elector
->
setGender
(
Elector
::
GENDER_MALE
);
$elector
->
setEmail
(
'kasper@typo3.org'
);
return
$this
->
getRenderedBody
(
$elector
);
}
/**
* @param Elector $elector
* @return string
*/
public
function
getRenderedBody
(
Elector
$elector
)
{
return
str_replace
(
[
'{elector.salutation}'
,
'{elector.firstName}'
,
'{elector.middleName}'
,
'{elector.lastName}'
,
'{elector.fullName}'
,
'{elector.email}'
,
'{electionCircular.link}'
,
],
[
$elector
->
getSalutation
(),
$elector
->
getFirstName
(),
$elector
->
getMiddleName
(),
$elector
->
getLastName
(),
$elector
->
getFullName
(),
$elector
->
getEmail
(),
$this
->
getLink
(
$elector
),
],
$this
->
body
);
}
/**
* @param Elector $elector
* @return string
*/
protected
function
getLink
(
Elector
$elector
)
{
return
'sakdjfhlkasdjhf'
;
}
}
Resources/Private/Language/locallang.xlf
View file @
43cc9f45
...
...
@@ -91,6 +91,12 @@
<trans-unit
id=
"view.be.dashboard.election_circular.list"
>
<source>
Election Circular
</source>
</trans-unit>
<trans-unit
id=
"view.be.dashboard.index.election_circulars"
>
<source>
Election Circulars
</source>
</trans-unit>
<trans-unit
id=
"view.be.dashboard.index.no_election_circulars"
>
<source>
There are no Election Circulars
</source>
</trans-unit>
<!-- BE CONFIGURATION-->
...
...
@@ -142,6 +148,15 @@
<trans-unit
id=
"model.abstract_person.field.full_name"
>
<source>
Name
</source>
</trans-unit>
<trans-unit
id=
"model.abstract_person.salutation.0"
>
<source/>
</trans-unit>
<trans-unit
id=
"model.abstract_person.salutation.1"
>
<source>
Mr.
</source>
</trans-unit>
<trans-unit
id=
"model.abstract_person.salutation.2"
>
<source>
Mrs.
</source>
</trans-unit>
<!-- MODEL CONFIGURATION-->
...
...
@@ -278,6 +293,7 @@
<trans-unit
id=
"model.nominee.field.image"
>
<source>
Image
</source>
</trans-unit>
<trans-unit
id=
"model.nominee.field.url"
>
<source>
URL
</source>
</trans-unit>
...
...
@@ -290,13 +306,24 @@
<trans-unit
id=
"model.nominee.field.public"
>
<source>
Public
</source>
</trans-unit>
</trans-unit>
<!-- BE ELECTION CIRCULARS -->
<trans-unit
id=
"view.be.election_circular.list.welcome"
>
<source>
Election Circulars
</source>
</trans-unit>
<trans-unit
id=
"view.be.election_circular.new.welcome"
>
<source>
Create a new Election Circular
</source>
</trans-unit>
<trans-unit
id=
"view.be.election_circular.edit.welcome"
>
<source>
Edit an Election Circular
</source>
</trans-unit>
<trans-unit
id=
"view.be.election_circular.send.welcome"
>
<source>
Send out the Circular
</source>
</trans-unit>
<trans-unit
id=
"view.be.election_circular.edit.save_and_send"
>
<source>
Save and send
</source>
</trans-unit>
<!-- MODEL ELECTION CIRCULARS -->
...
...
Resources/Private/Partials/Controller/BeElectionCircular/Edit/SaveAndSendButton.html
0 → 100644
View file @
43cc9f45
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<f:comment>
There's no "nice" way to send the form to another action
<f:render
partial=
"View/Menu/DropdownToggle"
/>
<ul
class=
"dropdown-menu"
>
<li>
<f:link.action
action=
"saveAndSend"
controller=
"BeElectionCircular"
>
<span
class=
"icon icon-size-small"
>
<span
class=
"icon-markup"
>
<core:icon
identifier=
"actions-move-right"
/>
</span>
</span>
<span>
<f:translate
key=
"view.be.election_circular.edit.save_and_send"
>
Save and send
</f:translate>
</span>
</f:link.action>
</li>
</ul>
</f:comment>
Resources/Private/Partials/Controller/BeElector/Import/UploadAndImportButton.html
View file @
43cc9f45
...
...
@@ -2,7 +2,7 @@
<div
class=
"btn-toolbar"
>
<div
class=
"btn-group"
>
<button
type=
"submit"
class=
"btn
btn-sm
btn-default"
form=
"{formId}"
>
<button
type=
"submit"
class=
"btn btn-default"
form=
"{formId}"
>
<span
class=
"icon icon-size-small"
>
<span
class=
"icon-markup"
>
<core:icon
identifier=
"actions-edit-upload"
/>
...
...
Resources/Private/Partials/Model/ElectionCircular/FormFields/Body.html
0 → 100644
View file @
43cc9f45
<fieldset
class=
"form-section"
>
<div
class=
"form-group"
>
<label>
<f:translate
key=
"model.election_circular.field.body"
>
Body
</f:translate>
</label>
<div
class=
"form-control-wrap"
style=
"max-width: 480px"
>
<f:form.textarea
rows=
"8"
class=
"form-control formengine-textarea"
property=
"body"
/>
</div>
<div>
<ul>
Available Marker:
<li>
<![CDATA[{elector.salutation}]]>
(Mr.| Mrs.)
<li>
<![CDATA[{elector.firstName}]]>
<li>
<![CDATA[{elector.middleName}]]>
<li>
<![CDATA[{elector.lastName}]]>
<li>
<![CDATA[{elector.fullName}]]>
(= FirstName + MiddleName + LastName)
<li>
<![CDATA[{elector.email}]]>
<li>
<![CDATA[{electionCircular.link}]]>
(clickable link to vote)
</ul>
</div>
</div>
</fieldset>
Resources/Private/Partials/Model/ElectionCircular/FormFields/Election.html
0 → 100644
View file @
43cc9f45
<fieldset
class=
"form-section"
>
<div
class=
"form-group"
>
<label>
<f:translate
key=
"model.election_circular.field.election"
>
election
</f:translate>
</label>
<div
class=
"form-control-wrap"
style=
"max-width: 480px"
>
<f:form.select
class=
"form-control"
property=
"election"
options=
"{elections}"
optionLabelField=
"title"
optionValueField=
"uid"
/>
</div>
</div>
</fieldset>
Resources/Private/Partials/Model/ElectionCircular/FormFields/Subject.html
0 → 100644
View file @
43cc9f45
<fieldset
class=
"form-section"
>
<div
class=
"form-group"
>
<label>
<f:translate
key=
"model.election_circular.field.subject"
>
subject
</f:translate>
</label>
<div
class=
"form-control-wrap"
style=
"max-width: 480px"
>
<f:form.textfield
class=
"form-control"
property=
"subject"
/>
</div>
</div>
</fieldset>
Resources/Private/Partials/Model/ElectionCircular/Forms/EditForm.html
0 → 100644
View file @
43cc9f45
<f:render
partial=
"Model/ElectionCircular/FormFields/Subject"
/>
<f:render
partial=
"Model/ElectionCircular/FormFields/Body"
/>
<f:render
partial=
"Model/ElectionCircular/FormFields/Election"
arguments=
"{elections:elections}"
/>
Resources/Private/Partials/Model/ElectionCircular/List.html
View file @
43cc9f45
...
...
@@ -6,9 +6,6 @@
<th>
<f:translate
key=
"model.election_circular.field.subject"
>
Subject
</f:translate>
</th>
<th>
<f:translate
key=
"model.election_circular.field.body"
>
Body
</f:translate>
</th>
<th>
<f:translate
key=
"model.election_circular.field.election"
>
Election
</f:translate>
</th>
...
...
@@ -25,9 +22,6 @@
{electionCircular.subject}
</f:link.action>
</td>
<td>
{electionCircular.body}
</td>
<td>
{electionCircular.election.title}
</td>
...
...
@@ -39,6 +33,9 @@
<f:link.action
class=
"btn btn-default"
action=
"delete"
controller=
"BeElectionCircular"
arguments=
"{electionCircular:electionCircular}"
>
<core:icon
identifier=
"actions-edit-delete"
/>
</f:link.action>
<f:link.action
class=
"btn btn-default"
action=
"send"
controller=
"BeElectionCircular"
arguments=
"{electionCircular:electionCircular}"
>
<core:icon
identifier=
"actions-move-right"
/>
</f:link.action>
</div>
</td>
</tr>
...
...
Resources/Private/Partials/Model/ElectionCircular/Send.html
0 → 100644
View file @
43cc9f45
<h1>
Preview
</h1>
<div
style=
"border: 1px solid black; padding: 10px;"
>
<h1>
{electionCircular.subject}
</h1>
<f:format.nl2br>
{electionCircular.dummyBody}
</f:format.nl2br>
</div>
Resources/Private/Partials/View/Menu/DropdownToggle.html
View file @
43cc9f45
<button
type=
"button"
class=
"btn
btn-sm
btn-default dropdown-toggle"
data-toggle=
"dropdown"
aria-expanded=
"false"
>
<button
type=
"button"
class=
"btn btn-default dropdown-toggle"
data-toggle=
"dropdown"
aria-expanded=
"false"
>
<span
class=
"caret"
></span>
<span
class=
"sr-only"
>
<f:translate
key=
"view.be.anything.dropdown.toggle"
>
Toggle Dropdown
</f:translate>
...
...
Resources/Private/Partials/View/Menu/FormButtons/Close.html
View file @
43cc9f45
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<f:link.action
class=
"btn btn-default
btn-sm
"
action=
"{returnAction}"
controller=
"{returnController}"
>
<f:link.action
class=
"btn btn-default"
action=
"{returnAction}"
controller=
"{returnController}"
>
<span
class=
"icon icon-size-small"
>
<span
class=
"icon-markup"
>
<core:icon
identifier=
"actions-document-close"
/>
...
...
Resources/Private/Partials/View/Menu/FormButtons/SaveAndClose.html
View file @
43cc9f45
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<button
type=
"submit"
class=
"btn
btn-sm
btn-default"
form=
"{formId}"
>
<button
type=
"submit"
class=
"btn btn-default"
form=
"{formId}"
>
<span
class=
"icon icon-size-small"
>
<span
class=
"icon-markup"
>
<core:icon
identifier=
"actions-document-save-close"
/>
...
...
Resources/Private/Partials/View/Menu/GlobalOptions.html
View file @
43cc9f45
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<style>
.btn.tx_election_election
{
background-color
:
lightblue
;
}
</style>
<f:be.security.ifHasRole
role=
"{configuration.electionManagerGroup}"
>
<f:link.action
class=
"btn btn-default"
action=
"list"
controller=
"BeNominee"
>
<f:link.action
class=
"btn btn-default
tx_election_election
"
action=
"list"
controller=
"BeNominee"
>
<f:translate
key=
"view.be.dashboard.nominee.list"
>
Nominees
</f:translate>
</f:link.action>
<f:link.action
class=
"btn btn-default"
action=
"list"
controller=
"BeElection"
>
<f:link.action
class=
"btn btn-default
tx_election_election
"
action=
"list"
controller=
"BeElection"
>
<f:translate
key=
"view.be.dashboard.election.list"
>
Elections
</f:translate>
</f:link.action>
<f:link.action
class=
"btn btn-default"
action=
"list"
controller=
"BeElectorate"
>
<f:link.action
class=
"btn btn-default
tx_election_election
"
action=
"list"
controller=
"BeElectorate"
>
<f:translate
key=
"view.be.dashboard.electorates.list"
>
Electorates
</f:translate>
</f:link.action>
<f:link.action
class=
"btn btn-default"
action=
"list"
controller=
"BeElector"
>
<f:link.action
class=
"btn btn-default
tx_election_election
"
action=
"list"
controller=
"BeElector"
>
<f:translate
key=
"view.be.dashboard.electors.list"
>
Electors
</f:translate>
</f:link.action>
<f:link.action
class=
"btn btn-default"
action=
"list"
controller=
"BeElectionCircular"
>
<f:link.action
class=
"btn btn-default
tx_election_election
"
action=
"list"
controller=
"BeElectionCircular"
>
<f:translate
key=
"view.be.dashboard.election_circular.list"
>
Election Circular
</f:translate>
</f:link.action>
</f:be.security.ifHasRole>
...
...
Resources/Private/Templates/BeDashboard/Index.html
View file @
43cc9f45
...
...
@@ -62,5 +62,18 @@
<f:translate
key=
"view.be.dashboard.index.no_elections"
>
There are no elections
</f:translate>
</f:else>
</f:if>
<h2>
<f:translate
key=
"view.be.dashboard.index.election_circulars"
>
Remaining Election Circulars
</f:translate>
</h2>
<f:if
condition=
"{electionCirculars}"
>
<f:then>
<f:render
partial=
"Model/ElectionCircular/List"
arguments=
"{electionCirculars:electionCirculars}"
/>
</f:then>
<f:else>
<f:translate
key=
"view.be.dashboard.index.no_election_circulars"
>
There are no election circulars
</f:translate>
</f:else>
</f:if>
</f:be.security.ifHasRole>
</f:section>
Resources/Private/Templates/BeElectionCircular/Edit.html
0 → 100644
View file @
43cc9f45
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<f:layout
name=
"Backend"
/>
<f:section
name=
"LeftToolBar"
>
<f:render
partial=
"View/Menu/FormButtons"
arguments=
"{
returnAction:'list',
returnController:'BeElectionCircular',
formId:'EditElectionCircular'
additionalButtonsPartial:'Controller/BeElectionCircular/Edit/SaveAndSendButton'
}"
/>
</f:section>
<f:section
name=
"RightToolBar"
>
</f:section>
<f:section
name=
"Welcome"
>
<h1>
<f:translate
key=
"view.be.election_circular.edit.welcome"
>
Edit an Election Circular
</f:translate>
</h1>
</f:section>
<f:section
name=
"Main"
>
<f:form
action=
"update"
object=
"{electionCircular}"
objectName=
"electionCircular"
id=
"EditElectionCircular"
method=
"post"
>
<f:render
partial=
"Model/ElectionCircular/Forms/EditForm"
arguments=
"{electionCircular:electionCircular,elections:elections}"
/>
</f:form>
</f:section>
Resources/Private/Templates/BeElectionCircular/New.html
0 → 100644
View file @
43cc9f45
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<f:layout
name=
"Backend"
/>
<f:section
name=
"LeftToolBar"
>
<f:render
partial=
"View/Menu/FormButtons"
arguments=
"{
returnAction:'list',
returnController:'BeElectionCircular',
formId:'NewElectionCircular'
}"
/>
</f:section>
<f:section
name=
"RightToolBar"
>
</f:section>
<f:section
name=
"Welcome"
>
<h1>
<f:translate
key=
"view.be.election_circular.new.welcome"
>
Create a new Election Circular
</f:translate>
</h1>
</f:section>
<f:section
name=
"Main"
>
<f:form
action=
"create"
object=
"{electionCircular}"
objectName=
"electionCircular"
id=
"NewElectionCircular"
method=
"post"
>
<f:render
partial=
"Model/ElectionCircular/Forms/EditForm"
arguments=
"{electionCircular:electionCircular,elections:elections}"
/>
</f:form>
</f:section>
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment