Commit 035daadf authored by Anna Ostrovskaya's avatar Anna Ostrovskaya Committed by Peter Tönnies

342-edit-food-basket

parent 9dc2beb1
Pipeline #32579814 passed with stages
in 21 minutes and 1 second
......@@ -8,6 +8,7 @@
- Only set session cookie when logged in !544 @nicksellen
- Added a second line to hover texts in stores #88 !547 @alex.simm
- New selection for expiration of baskets #340 !553 @alex.simm
- Possibility to edit food baskets #342 !549 @annaos
## Bugfixes
- Orga members are now able to leave stores they are not responsible for #283 !524 @annaos
......
......@@ -13,6 +13,47 @@ $g_lang['tel'] = 'Festnetztelefon';
$g_lang['lifetime'] = 'Wie lange soll Dein Essenskorb gültig sein?';
$g_lang['lifetime_options'] = ['einen Tag', 'zwei Tage', 'drei Tage', 'eine Woche', 'zwei Wochen', 'drei Wochen'];
$g_lang['set_date'] = 'Einstelldatum';
$g_lang['phone_contact'] = 'Telefonisch kontaktieren';
$g_lang['foodsaver_contact'] = '{name} kontaktieren';
$g_lang['provider'] = 'AnbieterIn';
$g_lang['create_at'] = 'Veröffentlicht am';
$g_lang['until'] = 'Gültig bis';
$g_lang['update_at'] = 'Geändert am';
$g_lang['basket_near'] = 'In Deiner Nähe';
$g_lang['no_requests'] = 'bisher keine Anfragen';
$g_lang['one_request'] = 'eine Anfrage';
$g_lang['req_count'] = '{count} Anfragen';
$g_lang['send_request'] = 'Anfrage absenden';
$g_lang['sent_request'] = 'Anfrage wurde versendet';
$g_lang['finish_request'] = 'Danke Dir! Der Vorgang ist abgeschlossen.';
$g_lang['baskets'] = 'Essenskörbe';
$g_lang['basket'] = 'Essenskorb';
$g_lang['basket_offer'] = 'Essenskorb anbieten';
$g_lang['basket_edit'] = 'Essenskorb bearbeiten';
$g_lang['basket_request'] = 'Essenskorb anfragen';
$g_lang['basket_request_on_page'] = 'Essenskorb anfragen auf unserer foodsharing-Homepage';
$g_lang['basket_delete'] = 'Essenskorb löschen';
$g_lang['basket_publish'] = 'Essenskorb veröffentlichen';
$g_lang['to_basket'] = 'zum Essenskorb';
$g_lang['basket_foodsaver'] = 'Essenskorb von {name}';
$g_lang['basket_foodsaver_close'] = 'Essenskorbanfrage von {name} abschließen';
$g_lang['basket_error'] = 'Essenskorb konnte nicht geladen werden.';
$g_lang['basket_error_message'] = 'Du hast keine Nachricht eingegeben';
$g_lang['basket_publish_error'] = 'Es gab einen Fehler. Der Essenskorb konnte nicht veröffentlicht werden.';
$g_lang['basket_publish_error_desc'] = 'Bitte gib eine Beschreibung ein!';
$g_lang['basket_publish_error_permission'] = 'Sie haben keine Rechte den Essenskorb zu bearbeiten.';
$g_lang['basket_publish_thank_you'] = 'Danke Dir! Der Essenskorb wurde veröffentlicht!';
$g_lang['basket_publish_error_address'] = 'Bitte gib in Deinem Profil eine Adresse ein!';
$g_lang['basket_deleted_picked_up'] = 'Ja, {gender} hat den Korb abgeholt.';
$g_lang['basket_not_picked_up'] = 'Nein, {gender} ist leider nicht wie verabredet erschienen.';
$g_lang['basket_deleted_other_reason'] = 'Die Lebensmittel wurden von jemand anderem abgeholt.';
$g_lang['basket_not_active'] = 'Essenskorb ist jetzt nicht mehr aktiv!';
$g_lang['basket_picked_up'] = 'Dieser Essenskorb wurde bereits abgeholt!';
$g_lang['basket_detail_login_hint'] = 'Für detaillierte Infos musst Du eingeloggt sein. Bist du noch nicht als Foodsharer registriert? Dann klick oben auf <b>Mach mit!</b> um loszulegen!';
$g_lang['basket_on_map'] = 'Alle Körbe auf der Karte';
$g_lang['not_login_hint'] = 'Du bist nicht eingeloggt, vielleicht ist Deine Session abgelaufen, bitte logge Dich ein und sende Deine Anfrage erneut ab.';
......@@ -234,3 +234,4 @@ $g_lang['menu_email_tpl'] = 'E-Mail-Vorlagen';
$g_lang['menu_blog'] = 'Blogbeiträge bearbeiten';
$g_lang['changelog'] = 'Changelog';
$g_lang['wallboard'] = 'Pinnwand';
ALTER TABLE `fs_basket`
ADD `update` DATETIME DEFAULT NULL after `time`;
......@@ -10,3 +10,7 @@
.findmap .vmap {
height: 400px;
}
div.ui-dialog textarea {
width: 98%;
}
......@@ -91,6 +91,7 @@ class BasketGateway extends BaseGateway
b.lon,
b.foodsaver_id,
UNIX_TIMESTAMP(b.time) AS time_ts,
UNIX_TIMESTAMP(b.update) AS update_ts,
UNIX_TIMESTAMP(b.until) AS until_ts,
fs.id AS fs_id,
fs.name AS fs_name,
......@@ -309,7 +310,23 @@ class BasketGateway extends BaseGateway
{
return $this->db->update(
'fs_basket',
['status' => Status::DELETED_OTHER_REASON],
[
'status' => Status::DELETED_OTHER_REASON,
'update' => date('Y-m-d H:i:s')
],
['id' => $id, 'foodsaver_id' => $fsId]
);
}
public function editBasket($id, $desc, $pic, $fsId): int
{
return $this->db->update(
'fs_basket',
[
'update' => date('Y-m-d H:i:s'),
'description' => strip_tags($desc),
'picture' => strip_tags($pic),
],
['id' => $id, 'foodsaver_id' => $fsId]
);
}
......
......@@ -10,10 +10,10 @@ class BasketView extends View
{
public function find($baskets, $location)
{
$page = new vPage('Essenskörbe', $this->findMap($location));
$page = new vPage($this->func->s('baskets'), $this->findMap($location));
if ($baskets) {
$page->addSectionRight($this->closeBaskets($baskets), 'In Deiner Nähe');
$page->addSectionRight($this->closeBaskets($baskets), $this->func->s('basket_near'));
}
$page->render();
......@@ -63,7 +63,7 @@ class BasketView extends View
$out .= '
</ul>
<div style="text-align:center;">
<a class="button" href="/karte?load=baskets">Alle Körbe auf der Karte</a>
<a class="button" href="/karte?load=baskets">' . $this->func->s('basket_on_map') . '</a>
</div>';
return $out;
......@@ -72,7 +72,7 @@ class BasketView extends View
public function basket($basket, $wallposts, $requests)
{
$page = new vPage(
'Essenskorb #' . $basket['id'], '
$this->func->s('basket') . ' #' . $basket['id'], '
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-3">
......@@ -85,17 +85,13 @@ class BasketView extends View
'
);
$page->setSubTitle(
'<p>Veröffentlicht am <strong>' . $this->func->niceDate(
$basket['time_ts']
) . '</strong></p><p>Gültig bis <strong>' . $this->func->niceDate($basket['until_ts']) . '</strong></p>'
);
$page->setSubTitle($this->getSubtitle($basket));
if ($wallposts) {
$page->addSection($wallposts, 'Pinnwand');
$page->addSection($wallposts, $this->func->s('wallboard'));
}
if ($this->session->may()) {
$page->addSectionRight($this->userBox($basket), 'AnbieterIn');
$page->addSectionRight($this->userBox($basket), $this->func->s('provider'));
if ($basket['lat'] != 0 || $basket['lon'] != 0) {
$map = new vMap([$basket['lat'], $basket['lon']]);
......@@ -109,11 +105,11 @@ class BasketView extends View
}
if ($basket['fs_id'] == $this->session->id() && $requests) {
$page->addSectionRight($this->requests($requests), count($requests) . ' Anfragen');
$page->addSectionRight($this->requests($requests), $this->func->sv('req_count', array('count' => count($requests))));
}
} else {
$page->addSectionRight(
$this->v_utils->v_info('Für detaillierte Infos musst Du eingeloggt sein. Bist du noch nicht als Foodsharer registriert? Dann klick oben auf <b>Mach mit!</b> um loszulegen!', 'Hinweis!'),
$this->v_utils->v_info($this->func->s('basket_detail_login_hint'), $this->func->s('reference')),
false,
array('wrapper' => false)
);
......@@ -125,11 +121,11 @@ class BasketView extends View
public function basketTaken($basket)
{
$page = new vPage(
'Essenskorb #' . $basket['id'], '
$this->func->s('basket') . ' #' . $basket['id'], '
<div class="pure-g">
<div class="pure-u-1 pure-u-md-2-3">
<p>Dieser Essenskorb wurde bereits abgeholt</p>
<p>' . $this->func->s('basket_picked_up') . '</p>
</div>
</div>
'
......@@ -157,14 +153,31 @@ class BasketView extends View
return $out;
}
private function userBox($basket)
private function getSubtitle($basket)
{
$request = '';
$subtitle = '<p>' . $this->func->s('create_at') . ' <strong>' . $this->func->niceDate(
$basket['time_ts']
) . '</strong>';
$subtitle .= '</p><p>' . $this->func->s('until') . ' <strong>' . $this->func->niceDate($basket['until_ts']) . '</strong></p>';
if ($basket['update_ts']) {
$subtitle .= '<p>' . $this->func->s('update_at') . ' <strong>' . $this->func->niceDate($basket['update_ts']) . '</strong></p>';
}
return $subtitle;
}
private function userBox($basket)
{
if ($basket['fs_id'] != $this->session->id()) {
$request = '<div><a class="button button-big" href="#" onclick="ajreq(\'request\',{app:\'basket\',id:' . (int)$basket['id'] . '});">Essenskorb anfragen</a> </div>';
$request = '<div><a class="button button-big" href="#" onclick="ajreq(\'request\',{app:\'basket\',id:' . (int)$basket['id'] . '});">' . $this->func->s('basket_request') . '</a> </div>';
} else {
$request = '<div><a class="button button-big" href="#" onclick="ajreq(\'removeBasket\',{app:\'basket\',id:' . (int)$basket['id'] . '});">Essenskorb löschen</a> </div>';
$request = '
<div class="ui-padding-bottom">
<a class="button button-big" href="#" onclick="ajreq(\'editBasket\',{app:\'basket\',id:' . (int)$basket['id'] . '});">' . $this->func->s('basket_edit') . '</a>
</div><div>
<a class="button button-big" href="#" onclick="ajreq(\'removeBasket\',{app:\'basket\',id:' . (int)$basket['id'] . '});">' . $this->func->s('basket_delete') . '</a>
</div>';
}
return $this->fsAvatarList(
......@@ -176,7 +189,7 @@ class BasketView extends View
'sleep_status' => $basket['sleep_status'],
),
),
array('height' => 60, 'scroller' => false)
array('height' => 600, 'scroller' => false)
) .
$request;
}
......@@ -285,6 +298,16 @@ class BasketView extends View
return $out;
}
public function basketEditForm($basket): string
{
$out = '';
$out .= $this->v_utils->v_form_textarea('description', array('maxlength' => 1705, 'value' => $basket['description']));
$out .= $this->v_utils->v_form_hidden('basket_id', $basket['id']);
return $out;
}
public function contactMsg(): string
{
return $this->v_utils->v_form_textarea('contactmessage');
......@@ -293,7 +316,7 @@ class BasketView extends View
public function contactTitle($basket): string
{
return '<img src="' . $this->func->img($basket['fs_photo']) . '" style="float:left;margin-right:15px;" />
<p>' . $basket['fs_name'] . ' kontaktieren</p>
<p>' . $this->func->sv('foodsaver_contact', array('name' => $basket['fs_name'])) . '</p>
<div style="clear:both;"></div>';
}
......@@ -302,13 +325,13 @@ class BasketView extends View
$out = '';
$content = '';
if (!empty($basket['tel'])) {
$content .= ('<tr><td>Festnetz: &nbsp;</td><td>' . $basket['tel'] . '</td></tr>');
$content .= ('<tr><td>' . $this->func->s('telefon') . ': &nbsp;</td><td>' . $basket['tel'] . '</td></tr>');
}
if (!empty($basket['handy'])) {
$content .= ('<tr><td>Handy: &nbsp;</td><td>' . $basket['handy'] . '</td></tr>');
$content .= ('<tr><td>' . $this->func->s('handy') . ': &nbsp;</td><td>' . $basket['handy'] . '</td></tr>');
}
if (!empty($content)) {
$out .= $this->v_utils->v_input_wrapper('Telefonisch kontaktieren', '<table>' . $content . '</table>');
$out .= $this->v_utils->v_input_wrapper($this->func->s('phone_contact'), '<table>' . $content . '</table>');
}
return $out;
......@@ -323,9 +346,9 @@ class BasketView extends View
return '
' . $img . '
' . $this->v_utils->v_input_wrapper('Beschreibung', nl2br($this->func->autolink($basket['description']))) . '
' . $this->v_utils->v_input_wrapper($this->func->s('desc'), nl2br($this->func->autolink($basket['description']))) . '
' .
'<div style="text-align:center;"><a class="fsbutton" href="' . BASE_URL . '/essenskoerbe/' . $basket['fsf_id'] . '" target="_blank">Essenskorb anfragen auf foodsharing.de</a></div>';
'<div style="text-align:center;"><a class="fsbutton" href="' . BASE_URL . '/essenskoerbe/' . $basket['fsf_id'] . '" target="_blank">' . $this->func->s('basket_request_on_page') . '</a></div>';
}
public function bubbleNoUser($basket): string
......@@ -337,7 +360,7 @@ class BasketView extends View
return '
' . $img . '
' . $this->v_utils->v_input_wrapper('Beschreibung', nl2br($this->func->autolink($basket['description']))) . '
' . $this->v_utils->v_input_wrapper($this->func->s('desc'), nl2br($this->func->autolink($basket['description']))) . '
';
}
......@@ -350,8 +373,8 @@ class BasketView extends View
return '
' . $img . '
' . $this->v_utils->v_input_wrapper('Einstelldatum', $this->func->niceDate($basket['time_ts'])) . '
' . $this->v_utils->v_input_wrapper('Beschreibung', nl2br($this->func->autolink($basket['description']))) . '
' . $this->v_utils->v_input_wrapper($this->func->s('set_date'), $this->func->niceDate($basket['time_ts'])) . '
' . $this->v_utils->v_input_wrapper($this->func->s('desc'), nl2br($this->func->autolink($basket['description']))) . '
';
}
}
This diff is collapsed.
......@@ -315,7 +315,7 @@ abstract class Control
<span id="wallpost-loader"></span><span id="wallpost-attach-image"><i class="far fa-image"></i> ' . $this->func->s('attach_image') . '</span>
<a href="#" id="wall-submit">' . $this->func->s('send') . '</a>
<div style="overflow:hidden;height:1px;">
<div style="overflow:hidden;height:0px;">
<form id="wallpost-attachimage-form" action="/xhrapp.php?app=wallpost&m=attachimage&table=' . $table . '&id=' . $id . '" method="post" enctype="multipart/form-data" target="wallpost-frame">
<input id="wallpost-attach-trigger" type="file" maxlength="100000" size="chars" name="etattach" />
</form>
......
......@@ -3,6 +3,7 @@
$I = new AcceptanceTester($scenario);
$description = sq('yay');
$updateDescription = sq('upd');
$pass = sq('pass');
$foodsaver = $I->createFoodsaver($pass);
......@@ -48,6 +49,20 @@ $I->seeInDatabase('fs_basket', [
$id = $I->grabFromDatabase('fs_basket', 'id', ['description' => $description,
'foodsaver_id' => $foodsaver['id']]);
//Check update of the foodbasket
$I->amOnPage($I->foodBasketInfoUrl($id));
$I->click('Essenskorb bearbeiten');
$I->waitForText('Essenskorb bearbeiten');
$I->fillField('description', $description . $updateDescription);
$I->click('Essenskorb veröffentlichen');
$I->waitForText('Geändert am');
$I->see($updateDescription);
$I->seeInDatabase('fs_basket', [
'description' => $description . $updateDescription,
'foodsaver_id' => $foodsaver['id']
]);
$picker = $I->createFoodsaver();
$nick = $I->haveFriend('nick');
......
  • Before approving / merging when there is a database change needed please talk to me or Matthias since the database change has to be done manually (as far as I know right now).

    I added the field to the database with the provided script - it should work now.

  • @k.miklobusec ah ok. I understood that this script is doing it for us automatically. That's why I had asked in the first place. Something learned... thanks and sorry.

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment