Commit 5a197d5c authored by Nicolas Jager's avatar Nicolas Jager

smartpanel : delete ring account from the panel

Change-Id: Ie40094e31cfb975ea7f518f068b6c38eb5504e6b
Tuleap: #1246
parent d8e49595
...@@ -37,20 +37,21 @@ public: ...@@ -37,20 +37,21 @@ public:
property bool _isSelected { property bool _isSelected {
void set(bool value) { void set(bool value) {
isSelected_ = value; isSelected_ = value;
NotifyPropertyChanged("_isSelected"); if (!_disconnected)
NotifyPropertyChanged("_isSelected");
} }
bool get() { bool get() {
return isSelected_; return isSelected_;
} }
} }
property bool _editionMode; property bool _editionMode;
property bool _disconnected;
protected: protected:
void NotifyPropertyChanged(String^ propertyName); void NotifyPropertyChanged(String^ propertyName);
private: private:
bool isSelected_; bool isSelected_;
}; };
} }
} }
......
...@@ -60,3 +60,14 @@ RingClientUWP::ViewModel::AccountListItemsViewModel::findItem(String^ accountId) ...@@ -60,3 +60,14 @@ RingClientUWP::ViewModel::AccountListItemsViewModel::findItem(String^ accountId)
return nullptr; return nullptr;
} }
void RingClientUWP::ViewModel::AccountListItemsViewModel::removeItem(AccountListItem ^ item)
{
unsigned int index;
itemsList_->IndexOf(item, &index);
item->_disconnected = true; // avoid disconected exception.
itemsList_->RemoveAt(index);
}
...@@ -43,6 +43,7 @@ internal: ...@@ -43,6 +43,7 @@ internal:
/* functions */ /* functions */
AccountListItem^ findItem(String^ accountId); AccountListItem^ findItem(String^ accountId);
void removeItem(AccountListItem^ item);
/* properties */ /* properties */
property Vector<AccountListItem^>^ itemsList property Vector<AccountListItem^>^ itemsList
......
...@@ -727,6 +727,8 @@ void RingClientUWP::Views::SmartPanel::_editAccountMenuButton__Click(Platform::O ...@@ -727,6 +727,8 @@ void RingClientUWP::Views::SmartPanel::_editAccountMenuButton__Click(Platform::O
auto account = AccountListItemsViewModel::instance->_selectedItem->_account; auto account = AccountListItemsViewModel::instance->_selectedItem->_account;
_aliasTextBoxEditionMenu_->Text = account->name_; _aliasTextBoxEditionMenu_->Text = account->name_;
_accountEditionMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible; _accountEditionMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_deleteAccountBtnEditionMenu_->IsChecked = false;
_deleteAccountBtnEditionMenu_->IsEnabled = (AccountListItemsViewModel::instance->itemsList->Size > 1)? true : false;
} }
...@@ -739,19 +741,19 @@ void RingClientUWP::Views::SmartPanel::_acceptAccountModification__Click(Platfor ...@@ -739,19 +741,19 @@ void RingClientUWP::Views::SmartPanel::_acceptAccountModification__Click(Platfor
// mettre ca en visibility du bouton delete // mettre ca en visibility du bouton delete
auto accountsListSize = dynamic_cast<Vector<AccountListItem^>^>(_accountsList_->ItemsSource)->Size; auto accountsListSize = dynamic_cast<Vector<AccountListItem^>^>(_accountsList_->ItemsSource)->Size;
/* if the delete button is toggled, just delete the account */
if (_deleteAccountBtnEditionMenu_->IsChecked && accountsListSize > 1) { if (_deleteAccountBtnEditionMenu_->IsChecked && accountsListSize > 1) {
RingD::instance->deleteAccount(accountId); AccountListItem^ item;
for each (item in AccountListItemsViewModel::instance->itemsList)
if (item->_account->accountID_ == accountId)
break;
/* rebuild a new list of accounts without the one to delete */ if (item)
auto newAccountList = ref new Vector<AccountListItem^>(); AccountListItemsViewModel::instance->removeItem(item);
for each (AccountListItem^ item in AccountListItemsViewModel::instance->itemsList) {
if (item->_account->accountID_ != accountId)
newAccountList->Append(item);
}
_accountsList_->ItemsSource = newAccountList; RingD::instance->deleteAccount(accountId);
} else { } else { /* otherwise edit the account */
account->name_ = _aliasTextBoxEditionMenu_->Text; account->name_ = _aliasTextBoxEditionMenu_->Text;
account->_upnpState = _upnpState_->IsOn; account->_upnpState = _upnpState_->IsOn;
...@@ -774,4 +776,4 @@ void RingClientUWP::Views::SmartPanel::_cancelAccountModification__Click(Platfor ...@@ -774,4 +776,4 @@ void RingClientUWP::Views::SmartPanel::_cancelAccountModification__Click(Platfor
void RingClientUWP::Views::SmartPanel::OnaccountUpdated(RingClientUWP::Account ^account) void RingClientUWP::Views::SmartPanel::OnaccountUpdated(RingClientUWP::Account ^account)
{ {
updatePageContent(); updatePageContent();
} }
\ No newline at end of file
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