Autofill profile does not update on creation and on reset 43/89143/2
authorKamil Nowac <k.nowac@samsung.com>
Wed, 21 Sep 2016 13:25:08 +0000 (15:25 +0200)
committerKamil Nowa? <k.nowac@samsung.com>
Fri, 23 Sep 2016 08:38:30 +0000 (01:38 -0700)
[Issue]    http://suprem.sec.samsung.net/jira/browse/TWF-2046
[Problem]  As in the title
[Solution] Added signal
[Verify]   Create profile ->
           Profile name should be updated
           Reset autofill data ->
           Profile name should be updated and
           all fields of form should be cleared

Change-Id: I31786adf0a0c444c2d6459485959e8c66123cf91

services/SettingsUI/SettingsAFCreator.cpp
services/SettingsUI/SettingsAFCreator.h
services/SettingsUI/SettingsAFProfile.cpp
services/SettingsUI/SettingsPrettySignalConnector.h
services/SettingsUI/SettingsUI.h
services/SimpleUI/SimpleUI.cpp

index d5ae0c2387aa5054234b57124db7ac7e669f7b9b..5f1b40bac9e75333b8b66ab8ba12684ea1c62b21 100644 (file)
@@ -37,12 +37,16 @@ SettingsAFCreator::SettingsAFCreator(Evas_Object* parent, bool profile_exists)
     , m_box(nullptr)
     , m_editErrorcode(update_error_none)
     , m_saveErrorcode(save_error_none)
-    , m_editFieldItemClass(nullptr)
     , m_item(nullptr)
     , m_ewkContext(ewk_context_default_get())
     , m_profile_exists(profile_exists)
+    , m_profile(nullptr)
 {
     init(parent);
+    SPSC.autoFillCleared.connect([this](){
+        m_profile_exists = false;
+        clearFields();
+    });
 };
 
 SettingsAFCreator::~SettingsAFCreator()
@@ -54,7 +58,6 @@ bool SettingsAFCreator::loadProfile(void)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
 
-    Ewk_Autofill_Profile* profile = nullptr;
     if (m_profile_exists) {
         void* item_data(nullptr);
         Eina_List* list(nullptr);
@@ -63,21 +66,21 @@ bool SettingsAFCreator::loadProfile(void)
 
         EINA_LIST_FOREACH(entire_item_list, list, item_data) {
             if (item_data) {
-                profile = static_cast<Ewk_Autofill_Profile*>(item_data);
+                m_profile = static_cast<Ewk_Autofill_Profile*>(item_data);
                 break;
             }
         }
     }
 
-    createNewAutoFillFormItem(profile);
+    createNewAutoFillFormItem();
 
     return false;
 }
 
-void SettingsAFCreator::createNewAutoFillFormItem(Ewk_Autofill_Profile* profile)
+void SettingsAFCreator::createNewAutoFillFormItem()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    if (!profile)
+    if (!m_profile)
         m_item  = std::make_shared<AutoFillFormItem>(nullptr);
     else {
         auto item_data = new AutoFillFormItemData;
@@ -86,17 +89,17 @@ void SettingsAFCreator::createNewAutoFillFormItem(Ewk_Autofill_Profile* profile)
             return;
         }
         memset(item_data, 0x00, sizeof(AutoFillFormItemData));
-        item_data->profile_id = ewk_autofill_profile_id_get(profile);
-        item_data->name = ewk_autofill_profile_data_get(profile, EWK_PROFILE_NAME);
-        item_data->company = ewk_autofill_profile_data_get(profile, EWK_PROFILE_COMPANY);
-        item_data->primary_address = ewk_autofill_profile_data_get(profile, EWK_PROFILE_ADDRESS1);
-        item_data->secondary_address = ewk_autofill_profile_data_get(profile, EWK_PROFILE_ADDRESS2);
-        item_data->city_town = ewk_autofill_profile_data_get(profile, EWK_PROFILE_CITY_TOWN);
-        item_data->state_province_region = ewk_autofill_profile_data_get(profile, EWK_PROFILE_STATE_PROVINCE_REGION);
-        item_data->post_code = ewk_autofill_profile_data_get(profile, EWK_PROFILE_ZIPCODE);
-        item_data->country = ewk_autofill_profile_data_get(profile, EWK_PROFILE_COUNTRY);
-        item_data->phone_number = ewk_autofill_profile_data_get(profile, EWK_PROFILE_PHONE);
-        item_data->email_address = ewk_autofill_profile_data_get(profile, EWK_PROFILE_EMAIL);
+        item_data->profile_id = ewk_autofill_profile_id_get(m_profile);
+        item_data->name = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_NAME);
+        item_data->company = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_COMPANY);
+        item_data->primary_address = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_ADDRESS1);
+        item_data->secondary_address = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_ADDRESS2);
+        item_data->city_town = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_CITY_TOWN);
+        item_data->state_province_region = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_STATE_PROVINCE_REGION);
+        item_data->post_code = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_ZIPCODE);
+        item_data->country = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_COUNTRY);
+        item_data->phone_number = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_PHONE);
+        item_data->email_address = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_EMAIL);
         item_data->activation = false;
         item_data->compose_mode = profile_edit;
 
@@ -194,6 +197,22 @@ void SettingsAFCreator::createInputLayout(
     evas_object_show(layout);
 }
 
+void SettingsAFCreator::clearFields()
+{
+    if (m_item) {
+        elm_object_part_text_set(m_fullNameItemCallbackData.entry, "elm.text", "");
+        elm_object_part_text_set(m_companyNameItemCallbackData.entry, "elm.text", "");
+        elm_object_part_text_set(m_addressLine1ItemCallbackData.entry, "elm.text", "");
+        elm_object_part_text_set(m_addressLine2ItemCallbackData.entry, "elm.text", "");
+        elm_object_part_text_set(m_cityTownItemCallbackData.entry, "elm.text", "");
+        elm_object_part_text_set(m_countryItemCallbackData.entry, "elm.text", "");
+        elm_object_part_text_set(m_postCodeItemCallbackData.entry, "elm.text", "");
+        elm_object_part_text_set(m_countryRegionItemCallbackData.entry, "elm.text", "");
+        elm_object_part_text_set(m_phoneItemCallbackData.entry, "elm.text", "");
+        elm_object_part_text_set(m_emailItemCallbackData.entry, "elm.text", "");
+    }
+}
+
 void SettingsAFCreator::addItems()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
index dbc3a31f48b3d30bf9750bd4ae7eaff75c5024a8..d7f048da989aeb066c39e28d57b3c0e1ee3de974 100644 (file)
@@ -42,7 +42,7 @@ public:
     virtual bool populateLayout(Evas_Object* genlist);
     Evas_Object* createScroller(Evas_Object *parent);
     bool loadProfile(void);
-    void createNewAutoFillFormItem(Ewk_Autofill_Profile*);
+    void createNewAutoFillFormItem();
 private:
     Eina_Bool isEntryHasOnlySpace(const char* field);
     Eina_Bool applyEntryData(void);
@@ -76,6 +76,7 @@ private:
         Evas_Object* it;
     };
     void createInputLayout(Evas_Object* parent, char* fieldName, genlistCallbackData* cb_data);
+    void clearFields();
     void addItems();
 protected:
     std::map<unsigned, ItemData> m_buttonsMap;
@@ -84,7 +85,6 @@ protected:
 
     profileEditErrorcode m_editErrorcode;
     profileSaveErrorcode m_saveErrorcode;
-    Elm_Genlist_Item_Class *m_editFieldItemClass;
     Elm_Entry_Filter_Limit_Size m_entryLimitSize;
 
     genlistCallbackData m_fullNameItemCallbackData;
@@ -100,6 +100,7 @@ protected:
     std::shared_ptr<AutoFillFormItem> m_item;
     Ewk_Context* m_ewkContext;
     bool m_profile_exists;
+    Ewk_Autofill_Profile* m_profile;
 };
 
 }
index 5771202a95216c337b67ca092fd4d83056a34509..363db1a1bf0a30b32952d8ce842056cc0f148635 100644 (file)
@@ -27,6 +27,10 @@ SettingsAFProfile::SettingsAFProfile(Evas_Object* parent)
 {
     init(parent);
     SPSC.setProfileName.connect([this](std::string name){m_profileName = name;});
+    SPSC.autoFillCleared.connect([this](){
+        m_profileName.clear();
+        m_profile = nullptr;
+    });
 };
 
 SettingsAFProfile::~SettingsAFProfile()
@@ -50,11 +54,11 @@ void SettingsAFProfile::updateButtonMap()
             break;
         }
     }
-    if (!m_profile)
+    profileName.buttonText = m_profile ?
+        profileName.buttonText = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_NAME) :
         profileName.buttonText = _(Translations::SettingsAutoFillProfileSetMyProfile.c_str());
-    else if (m_profileName.empty())
-        profileName.buttonText = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_NAME);
-    else
+
+    if (!m_profileName.empty())
         profileName.buttonText = m_profileName;
     m_itemData = std::make_shared<ItemData>(profileName);
 }
index b1d66fc70b0d59d49052dd2bbab3b3d68efc11d8..947ee2a3ac890d240a2e3860dcc9100f5fc413cc 100644 (file)
@@ -74,6 +74,7 @@ public:
     B_SIG<void (int)> setContentDestination;
     B_SIG<void ()> showTextPopup;
     B_SIG<void (std::string)> setProfileName;
+    B_SIG<void ()> autoFillCleared;
 
 private:
     SettingsPrettySignalConnector(){};
index cb0aa280b74c9d89fb3a5bd97d8399478cf9759f..3cc046609e42fe6c3068323c619196711e9c7686 100644 (file)
@@ -72,6 +72,7 @@ public:
             Elm_Gengrid_Item_Class* it_class,
             const void *data,
             Evas_Smart_Cb func);
+    void prepareLayout(Evas_Object* layout);
     Evas_Object* createActionBar(Evas_Object* settings_layout);
     Evas_Object* createSettingsMobilePage(Evas_Object* settings_layout);
     Evas_Object* createMainView(Evas_Object* settings_layout);
index 228fad9ff981603542e08eaec6b99c16b1ea4d65..fa756798e58f9a32b0c6a57c27d93ab7e10ad8d4 100755 (executable)
@@ -1886,6 +1886,7 @@ void SimpleUI::onDeleteSelectedDataButton(const PopupButtons& button, const std:
             } else if (it.first == DEL_PERS_AUTO_FILL && it.second) {
                 BROWSER_LOGD("clear autofill forms");
                 m_webEngine->clearFormData();
+                SPSC.autoFillCleared();
             } else if (it.first == LOCATION && it.second) {
                 BROWSER_LOGD("clear location");
             }