[dev] [commit] r1018 - templates/admin wwwbase/admin wwwbase/ajax wwwbase/js wwwbase/styles
automailer at dexonline.ro
automailer at dexonline.ro
Mon Oct 7 15:52:35 EEST 2013
Author: grigoroiualex
Date: Mon Oct 7 15:52:34 2013
New Revision: 1018
Log:
Saved tags from visualTag page are now showed in a jqGrid table instead of plain text.
New 3 columns layout.
TODO: edit and save actions directly from table.
Added:
wwwbase/ajax/getSavedTags.php
wwwbase/ajax/visualTagsEdit.php
Deleted:
wwwbase/ajax/visualTag.php
Modified:
templates/admin/visualTag.ihtml
wwwbase/admin/visualTag.php
wwwbase/js/visualTag.js
wwwbase/styles/flex.css
Modified: templates/admin/visualTag.ihtml
==============================================================================
--- templates/admin/visualTag.ihtml Sun Oct 6 02:11:22 2013 (r1017)
+++ templates/admin/visualTag.ihtml Mon Oct 7 15:52:34 2013 (r1018)
@@ -50,7 +50,7 @@
<div id="tagOptions">
<form action="visualTag.php" method="post">
- <input type="hidden" value="{$imageId}" name="imageId"/>
+ <input id="imageId" type="hidden" value="{$imageId}" name="imageId"/>
<p>
Informații imagine<br/><br/>
Imaginea este atribuită cuvântului: {$lexemeName}.
@@ -89,15 +89,8 @@
</div>
<div id="savedTags">
- <h3>Etichete salvate</h3>
- {foreach from=$savedTags item=tag}
- <form action="visualTag.php" method="post">
- <label>{$tag->label}
- <input type="hidden" name="savedTagId" value="{$tag->id}"/>
- <button type="submit" name="action" value="delete">Șterge eticheta</button>
- </label>
- </form>
- {/foreach}
+ <table id="tagsGrid"></table>
+ <div id="tagsPaging"></div>
</div>
<script type="text/javascript">
Modified: wwwbase/admin/visualTag.php
==============================================================================
--- wwwbase/admin/visualTag.php Sun Oct 6 02:11:22 2013 (r1017)
+++ wwwbase/admin/visualTag.php Mon Oct 7 15:52:34 2013 (r1018)
@@ -100,6 +100,6 @@
}
SmartyWrap::assign('sectionTitle', 'Etichetare imagini pentru definiții');
-SmartyWrap::addCss('jcrop', 'select2');
-SmartyWrap::addJs('jquery', 'jcrop', 'visualTag', 'select2', 'select2Dev');
+SmartyWrap::addCss('jcrop', 'select2', 'jqgrid', 'jqueryui');
+SmartyWrap::addJs('jquery', 'jcrop', 'visualTag', 'select2', 'select2Dev', 'jqgrid');
SmartyWrap::displayAdminPage('admin/visualTag.ihtml');
Added: wwwbase/ajax/getSavedTags.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ wwwbase/ajax/getSavedTags.php Mon Oct 7 15:52:34 2013 (r1018)
@@ -0,0 +1,17 @@
+<?php
+
+require_once("../../phplib/util.php");
+
+$imageId = util_getRequestParameter('imageId');
+$resp = array();
+$lines = VisualTag::get_all_by_imageId($imageId);
+
+foreach ($lines as $line) {
+ $row = Lexem::get_by_id($line->lexemeId);
+ $resp[] = array('id' => $line->id, 'label' => $line->label, 'xTag' => $line->textXCoord,
+ 'yTag' => $line->textYCoord, 'xImg' => $line->imgXCoord,
+ 'yImg' => $line->imgYCoord, 'lexeme' => !empty($row) ? $row->formUtf8General : '');
+}
+
+echo json_encode($resp);
+?>
\ No newline at end of file
Deleted: wwwbase/ajax/visualTag.php
==============================================================================
--- wwwbase/ajax/visualTag.php Mon Oct 7 15:52:34 2013 (r1017)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,16 +0,0 @@
-<?php
-require_once('../../phplib/util.php');
-
-$query = util_getRequestParameter('term');
-
-$field = StringUtil::hasDiacritics($query) ? 'formNoAccent' : 'formUtf8General';
-
-$lexems = Model::factory('Lexem')->where_like($field, "{$query}%")->order_by_asc('formNoAccent')->limit(10)->find_many();
-
-$resp = array('more' => 'false', 'results' => array());
-foreach($lexems as $lexem) {
- $resp['results'][] = array('id' => $lexem->id, 'text' => (string)$lexem->formUtf8General, 'description' => (string)$lexem->description);
-}
-
-echo json_encode($resp);
-?>
Added: wwwbase/ajax/visualTagsEdit.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ wwwbase/ajax/visualTagsEdit.php Mon Oct 7 15:52:34 2013 (r1018)
@@ -0,0 +1,18 @@
+<?php
+require_once("../../phplib/util.php");
+
+$oper = util_getRequestParameter('oper');
+$id = util_getRequestParameter('id');
+
+switch ($oper) {
+ case 'del' :
+ $line = VisualTag::get_by_id($id);
+ if(!empty($line)) {
+ $line->delete();
+ }
+ break;
+
+ default:
+ break;
+}
+?>
Modified: wwwbase/js/visualTag.js
==============================================================================
--- wwwbase/js/visualTag.js Sun Oct 6 02:11:22 2013 (r1017)
+++ wwwbase/js/visualTag.js Mon Oct 7 15:52:34 2013 (r1018)
@@ -57,6 +57,46 @@
$('#toggleHelp').click(function() {
$('#helpText').toggle();
});
+
+ $('#tagsGrid').jqGrid({
+ url: wwwRoot + 'ajax/getSavedTags.php',
+ postData: {imageId: $('#imageId').val()},
+ datatype: 'json',
+ colNames: ['Id', 'Lexem', 'Text afișat', 'X Etichetă', 'Y Etichetă', 'X Imagine', 'Y Imagine'],
+ colModel: [
+ {name: 'id', index: 'id', hidden: true},
+ {name: 'lexeme', index: 'lexeme', width: 80, align: 'center'},
+ {name: 'label', index: 'label', width: 100, align: 'center'},
+ {name: 'xTag', index: 'xTag', width: 55, align: 'center'},
+ {name: 'yTag', index: 'yTag', width: 55, align: 'center'},
+ {name: 'xImg', index: 'yImg', width: 55, align: 'center'},
+ {name: 'yImg', index: 'yImg', width: 55, align: 'center'}
+ ],
+ rowNum: 20,
+ recreateForm: true,
+ width: '430px',
+ height: '100%',
+ rowList: [20, 50, 100, 200],
+ sortname: 'id',
+ pager: $('#tagsPaging'),
+ viewrecords: true,
+ sortorder: 'desc',
+ caption: 'Etichete salvate',
+ editurl: wwwRoot + 'ajax/visualTagsEdit.php'
+ })
+ .navGrid('#tagsPaging',
+ {
+ add: false,
+ edit: false,
+ search: false,
+ deltitle: 'Șterge',
+ refreshtitle: 'Actualizează'
+ },
+ {}, {},
+ {
+ afterSubmit: checkServerResponse
+ }
+ );
});
/** Replaces the submit event that triggers on change, set in select2Dev.js */
@@ -103,3 +143,11 @@
return false;
}
};
+
+function checkServerResponse(response, postData) {
+ if (response.responseText) {
+ return [false, response.responseText];
+ } else {
+ return [true];
+ }
+}
Modified: wwwbase/styles/flex.css
==============================================================================
--- wwwbase/styles/flex.css Sun Oct 6 02:11:22 2013 (r1017)
+++ wwwbase/styles/flex.css Mon Oct 7 15:52:34 2013 (r1018)
@@ -396,3 +396,14 @@
#helpText {
display: none;
}
+
+#tagOptions {
+ float: left;
+ width: 320px;
+ margin: 0 0 15px 13px;
+}
+
+#savedTags {
+ float: left;
+ width: 430px;
+}
More information about the Dev
mailing list