Skip to content
This repository has been archived by the owner on Sep 4, 2022. It is now read-only.

Commit

Permalink
add ordering in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinKolodnitsky committed Feb 18, 2015
1 parent 5f404d4 commit 2d07345
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions api/endpoint/v1/requirement.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ function init() {
function get_getForQuote() {
$quote_id = $this->getQuoteId();
$this->model->prepareForSelect($this->app->current_user);
$this->model->addCondition('quote_id',$quote_id)->addCondition('is_deleted',false);
$this->model
->addCondition('quote_id',$quote_id)
->addCondition('is_deleted',false)
->setOrder('order',false);
try{
$data = $this->model->getRows();
return[
Expand All @@ -40,6 +43,9 @@ private function getQuoteId() {
return $quote_id;
}

/**
* @return array
*/
public function post_updateOrder(){
$quote_id = $this->checkGetParameter('quote_id');
$ids = $this->getFancyPost();
Expand All @@ -57,10 +63,8 @@ public function post_updateOrder(){
foreach ($this->model as $row) {
$row->set('order',$ids_arr[$row->id])->saveAndUnload();
}
$data = $this->model->prepareForSelect($this->app->current_user)->getRows();//TODO this returns nothing
return[
'result' => 'success',
'data' => $data,
];
}catch (Exception $e){
return[
Expand Down
2 changes: 1 addition & 1 deletion lib/Helper/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function checkGetParameter($name,$can_by_null=false) {
];
}
}
protected function checkPostParameter($name,$can_by_null=false) {//TODO This method does not work. Kostua. 17.02.2015
protected function checkPostParameter($name,$can_by_null=false) {//TODO This method does not work. Kostya. 17.02.2015
if (isset($_POST[$name])) {
return $_POST[$name];
}
Expand Down
6 changes: 3 additions & 3 deletions shared/lib/Model/Requirement.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function prepareForSelect(Model_User $u){
$fields = ['id'];

if($r->canSeeQuotes($u['id'])){
$fields = array('id','quote_id','quote','user_id','user','name','descr','estimate','is_included','file_id','file','is_deleted','deleted_id','deleted','project_id','project_name','spent_time','count_comments');
$fields = array('id','quote_id','quote','user_id','user','name','descr','estimate','is_included','file_id','file','is_deleted','deleted_id','deleted','project_id','project_name','spent_time','count_comments','order');
}else{
throw $this->exception('This User cannot see projects','API_CannotSee');
}
Expand All @@ -111,7 +111,7 @@ function prepareForInsert(Model_User $u){
$fields = ['id'];

if($r->canAddRequirement($u['id'])){
$fields = array('id','quote_id','quote','user_id','user','name','descr','estimate','is_included','file_id','file','is_deleted','deleted_id','deleted','project_id','project_name','spent_time','count_comments');
$fields = array('id','quote_id','quote','user_id','user','name','descr','estimate','is_included','file_id','file','is_deleted','deleted_id','deleted','project_id','project_name','spent_time','count_comments','order');
}else{
throw $this->exception('This User cannot add projects','API_CannotAdd');
}
Expand All @@ -132,7 +132,7 @@ function prepareForUpdate(Model_User $u){
$fields = ['id'];

if($r->canEditRequirement($u['id'])){
$fields = array('id','quote_id','quote','user_id','user','name','descr','estimate','is_included','file_id','file','is_deleted','deleted_id','deleted','project_id','project_name','spent_time','count_comments');
$fields = array('id','quote_id','quote','user_id','user','name','descr','estimate','is_included','file_id','file','is_deleted','deleted_id','deleted','project_id','project_name','spent_time','count_comments','order');
}else{
throw $this->exception('This User cannot edit quotes','API_CannotEdit');
}
Expand Down

0 comments on commit 2d07345

Please sign in to comment.