]> gitweb.hamatoma.de Git - gadeku.git/commitdiff
0.1.6 Verbesserungen in Phrase
authorHamatoma <author@hamatoma.de>
Thu, 11 Apr 2024 20:53:08 +0000 (22:53 +0200)
committerHamatoma <author@hamatoma.de>
Thu, 11 Apr 2024 20:53:08 +0000 (22:53 +0200)
Added:
- Phrases:
  - Anzeige Übersetzung
  - Combobox "Sprache" in Tabelle integriert.

Changed
- Phrases:
  - Autoupdate von Combobox "Sprache"

CHANGELOG.md
app/Http/Controllers/PhraseController.php
composer.lock
lang/de_DE.json
resources/lang/sources/gadeku.de.json
resources/views/phrase/index.blade.php

index 6bf25acc24e228960892ee8e75ff0847e9f712e6..0cbfcc38686458c504ca6af37a3a0f84e09b70d9 100644 (file)
@@ -1,3 +1,14 @@
+# V 0.1.6 Verbesserungen in Phrase
+
+# Added:
+- Phrases:
+  - Anzeige Übersetzung
+  - Combobox "Sprache" in Tabelle integriert.
+
+# Changed
+- Phrases:
+  - Autoupdate von Combobox "Sprache"
+
 # V 0.1.5 Phrases: Übersetzung
 
 # Added:
index 3a01dd09cc73bc535999ff57c13af66aba83543e..3f47a1af9845bf350cecdf7220e190aca4b405b0 100644 (file)
@@ -61,7 +61,7 @@ class PhraseController extends Controller
             $rc = redirect('/phrase-index');
         } else {
             $fields = $request->all();
-            if (count($fields) === 1){
+            if (count($fields) === 1) {
                 $fields = [
                     'phrase' => '',
                     'language' => $request->language,
@@ -76,9 +76,9 @@ class PhraseController extends Controller
                     'translation' => ''
                 ];
             }
-            if ($fields['lastLanguage'] != $fields['language']){
+            if ($fields['lastLanguage'] != $fields['language']) {
                 $phraseTranslation = Phrase::where(['language_scope' => $fields['language'], 'phrase_id' => $phrase->id])->first();
-                if ($phraseTranslation != null){
+                if ($phraseTranslation != null) {
                     $fields['translation'] = $phraseTranslation->phrase;
                 }
             }
@@ -110,47 +110,56 @@ class PhraseController extends Controller
         if ($request->btnSubmit === 'btnNew') {
             return redirect('/phrase-create');
         } else {
-            $sql = 'SELECT t0.*,'
-                . 't1.name as language_scope, '
-                . 't2.name as owner_id, '
-                . 't3.name as verifiedby_id '
-                . ' FROM phrases t0'
-                . ' LEFT JOIN sproperties t1 ON t1.id=t0.language_scope'
-                . ' LEFT JOIN sproperties t2 ON t2.id=t0.owner_id'
-                . ' LEFT JOIN sproperties t3 ON t3.id=t0.verifiedby_id'
-            ;
-            $parameters = [];
             $fields = $request->all();
+            $lang = count($fields) == 0 ? SProperty::idOfLocalization() : $fields['language'];
+            $sql = "
+SELECT t0.*,
+    t1.name as language_scope, 
+    (select phrase from phrases t4 where t4.phrase_id=t0.id and t4.language_scope=$lang) as translation
+FROM phrases t0
+LEFT JOIN sproperties t1 ON t1.id=t0.language_scope
+LEFT JOIN users t2 ON t2.id=t0.owner_id
+";
+            $parameters = [];
+            $conditions = [];
             if (count($fields) == 0) {
                 $fields = [
-                    'language' => '',
+                    'language' => SProperty::idOfLocalization(),
                     'word' => '',
                     'phrase' => '',
                     'owner' => '',
-                    'verifiedby' => '',
+                    'verified' => '',
                     '_sortParams' => 't0.phrase:asc;t0.id:desc'
                 ];
             } else {
-                $conditions = [];
-                ViewHelper::addConditionComparism($conditions, $parameters, 'language_scope', 'language');
-                ViewHelper::addConditionComparism($conditions, $parameters, 'owner_id', 'owner');
-                ViewHelper::addConditionComparism($conditions, $parameters, 'verifiedby_id', 'verifiedby');
-                ViewHelper::addConditionPattern($conditions, $parameters, 'phrase', 'text');
-                $sql = DbHelper::addConditions($sql, $conditions);
+                ViewHelper::addConditionComparism($conditions, $parameters, 't0.owner_id', 'owner');
+                $lang = $fields['language'];
+                if ($fields['verified'] != null) {
+                    // 1: not verified 2: verified
+                    $not = $fields['verified'] == 1 ? '' : ' NOT';
+                    array_push($conditions, "EXISTS(SELECT id FROM phrases ph WHERE ph.id=t0.phrase_id AND ph.language_scope=$lang AND ph.verifiedby_id IS$not NULL)");
+                }
+                ViewHelper::addConditionPattern($conditions, $parameters, 't0.phrase', 'text');
             }
+            ViewHelper::addConditionConstComparison($conditions, $parameters, 't0.language_scope', 1202);
+            $sql = DbHelper::addConditions($sql, $conditions);
             $sql = DbHelper::addOrderBy($sql, $fields['_sortParams']);
             $pagination = new Pagination($sql, $parameters, $fields);
             $records = $pagination->records;
-            $optionsLanguage = SProperty::optionsByScope('language', $fields['language'], 'all');
-            $optionsOwner = DbHelper::comboboxDataOfTable('users', 'name', 'id', $fields['owner'], __('<Please select>'));
-            $optionsVerifiedby = DbHelper::comboboxDataOfTable('users', 'name', 'id', $fields['verifiedby'], __('<Please select>'));
+            $optionsLanguage = SProperty::optionsByScope('localization', $fields['language']);
+            $optionsOwner = DbHelper::comboboxDataOfTable('users', 'name', 'id', $fields['owner'], __('<All>'));
+            $optionsVerified = [
+                ['text' => __('<All>'), 'value' => '', 'active' => $fields['verified'] == ''],
+                ['text' => __('Not verified'), 'value' => 1, 'active' => $fields['verified'] == 1],
+                ['text' => __('Verified'), 'value' => 2, 'active' => $fields['verified'] == 2]
+            ];
             $context = new ContextLaraKnife($request, $fields);
+            $context->setCombobox('language', 'Language', $optionsLanguage, '', 'lkn-autoupdate');
             return view('phrase.index', [
                 'context' => $context,
                 'records' => $records,
-                'optionsLanguage' => $optionsLanguage,
                 'optionsOwner' => $optionsOwner,
-                'optionsVerifiedby' => $optionsVerifiedby,
+                'optionsVerified' => $optionsVerified,
                 'pagination' => $pagination
             ]);
         }
@@ -165,7 +174,7 @@ class PhraseController extends Controller
             'phrase' => 'required',
             'translation' => 'required',
         ];
-        if ($isCreate){
+        if ($isCreate) {
             $rc['language'] = 'required';
         }
         return $rc;
@@ -235,7 +244,7 @@ class PhraseController extends Controller
     public function update(Phrase $phrase, Request $request)
     {
         $rc = null;
-        if ($request->btnSubmit === 'btnInternal'){
+        if ($request->btnSubmit === 'btnInternal') {
             // Language combobox has been changed:
             $url = "/phrase-edit/$phrase->id?language=" . $request->language;
             $rc = redirect($url);
@@ -270,7 +279,7 @@ class PhraseController extends Controller
                     ]);
                 } else {
                     // Update only if changed:
-                    if ($phraseTranslation->phrase !== $validated['translation']){
+                    if ($phraseTranslation->phrase !== $validated['translation']) {
                         $phraseTranslation->update(['phrase' => $validated['translation'], 'verifiedby_id' => null]);
                     }
                 }
index 71b1ec6f525aeea462abd7f1d62b42a4c5629959..e336d5044e98d286e814030c35d7befc2537772b 100644 (file)
             "dist": {
                 "type": "path",
                 "url": "../laraknife",
-                "reference": "75f027bc39816f480246d553ef5b996fed7a775e"
+                "reference": "47a41b7a9e0479870ed354c33653009296af812d"
             },
             "require-dev": {
                 "phpunit/phpunit": "11.0.x-dev"
         },
         {
             "name": "laravel/framework",
-            "version": "v11.3.0",
+            "version": "v11.3.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laravel/framework.git",
-                "reference": "cbcb0ee3da8c5f98497d9a282609732251a7dd1e"
+                "reference": "3b87d0767e9cbddec46480d883010ba720e50dea"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laravel/framework/zipball/cbcb0ee3da8c5f98497d9a282609732251a7dd1e",
-                "reference": "cbcb0ee3da8c5f98497d9a282609732251a7dd1e",
+                "url": "https://api.github.com/repos/laravel/framework/zipball/3b87d0767e9cbddec46480d883010ba720e50dea",
+                "reference": "3b87d0767e9cbddec46480d883010ba720e50dea",
                 "shasum": ""
             },
             "require": {
                 "issues": "https://github.com/laravel/framework/issues",
                 "source": "https://github.com/laravel/framework"
             },
-            "time": "2024-04-09T15:19:11+00:00"
+            "time": "2024-04-10T15:13:49+00:00"
         },
         {
             "name": "laravel/prompts",
index 11e4e3698834fee42c1e04de161f167816d1665a..9ce4bbc89e013bfa4a0f9f69744d50960f1917fe 100644 (file)
@@ -2,6 +2,7 @@
     "!comment": "Bitte alphabetisch sortiert eintragen!",
     "&lt;All&gt;": "&lt;Alle&gt;",
     "<All>": "<Alle>",
+    "<Not verified>": "<Nicht verifiziert>",
     "<Please select>": "<Bitte w\u00e4hlen>",
     "A Scoped Property": "Eine bereichsbasierte Eigenschaft",
     "Action": "Aktion",
@@ -78,6 +79,7 @@
     "Name": "Name",
     "New": "Neu",
     "Not Assigned Menu Items": "Nicht zugeordnete Men\u00fceintr\u00e4ge",
+    "Not verified": "Nicht \u00fcberpr\u00fcft",
     "Notes": "Notizen",
     "Noun": "Nomen",
     "Nouns": "Nomen",
     "Value": "Wert",
     "Verb": "Verb",
     "Verbs": "Verben",
+    "Verified": "\u00dcberpr\u00fcft",
     "Verified by": "\u00dcberpr\u00fcft von",
     "Verifiedby": "\u00dcberpr\u00fcft von",
     "Visibility": "Sicherbarkeit",
index 2a3f002c521dd91f32e670a9bfb8982c263515ef..eee27ca8dde04c1ea8b5241f46c117dfe4ddb76e 100644 (file)
@@ -1,5 +1,6 @@
 {
 "!comment": "Bitte alphabetisch sortiert eintragen!",
+"<Not verified>": "<Nicht verifiziert>",
 "Adjective": "Adjektiv",
 "Change of a Noun": "Änderung eines Nomens",
 "Change of a Phrase": "Änderung eines Satzes",
@@ -14,6 +15,7 @@
 "Imperfect": "Imperfekt",
 "masculine": "Maskulinum",
 "neuter": "Neutrum",
+"Not verified": "Nicht überprüft",
 "Noun": "Nomen",
 "Nouns": "Nomen",
 "Participle": "Partizip",
@@ -27,6 +29,7 @@
 "Words": "Wörter",
 "Wordtype": "Wortart",
 "Usage": "Verwendung",
+"Verified": "Überprüft",
 "Verifiedby": "Überprüft von",
 "Verified by": "Überprüft von",
 "ZZZZZ_last": ""
index 5d1cd88eb424eb9c08803e66b699d26fda979580..06bf963ad9d6bc66bcf5a95077145d6392c38c22 100644 (file)
@@ -6,18 +6,15 @@
     <x-laraknife.panels.index title="{{ __('Phrases') }}">
       <x-laraknife.panels.filter legend="{{ $pagination->legendText() }}">
         <x-laraknife.forms.combobox position="first" name="owner" label="Owner" :options="$optionsOwner" class="lkn-autoupdate" width2="4" />
-        <x-laraknife.forms.combobox position="last" name="verifiedby" label="Verifiedby" :options="$optionsVerifiedby" class="lkn-autoupdate" width2="4" />
-        <x-laraknife.forms.string position="first" name="text" label="Text" value="{{ $context->valueOf('text') }}" width2="4" />
-        <x-laraknife.forms.combobox position="last" name="language" label="Language" :options="$optionsLanguage" class="lkn-autoupdate" width2="4" />
+        <x-laraknife.forms.combobox position="last" name="verified" label="Verified" :options="$optionsVerified" class="lkn-autoupdate" width2="4" />
+        <x-laraknife.forms.string position="alone" name="text" label="Text" value="{{ $context->valueOf('text') }}" width2="4" />
       </x-laraknife.panels.filter>
       <x-laraknife.panels.sortable-table :context="$context" :pagination="$pagination">
         <thead>
           <tr>
             <th></th>
             <th sortId="phrase">{{__('Phrase')}}</th>
-            <th sortId="language_scope">{{__('Language')}}</th>
-            <th sortId="owner_id">{{__('Owner')}}</th>
-            <th sortId="verifiedby_id">{{__('Verifiedby')}}</th>
+            <th sortId="translation">{{__('Translation')}}</th>
             <th></th>
           </tr>
         </thead>
@@ -26,9 +23,7 @@
         <tr>
             <td><x-laraknife.icons.change-record module="phrase" no="{{ $phrase->id }}" /></td>
               <td>{{$phrase->phrase}}</td>
-              <td> {{ __($phrase->language_scope) }}</td>
-              <td>{{$phrase->owner_id}}</td>
-              <td>{{$phrase->verifiedby_id}}</td>
+              <td> {{ __($phrase->translation) }}</td>
             <td><x-laraknife.icons.delete-record module="phrase" no="{{ $phrase->id }}" /></td>
         </tr>
 @endforeach