Commits

Juan Carlos Picado Herrera committed 664ebe6

Support to publish poll on multiple social networks

  • Participants
  • Parent commits fcde03a

Comments (0)

Files changed (7)

File enme-war/src/main/webapp/resource/css-compile/web/components/publish-support.css

     background-color: #F4F4F4;
     border-top: 2px solid #D7D7D7;
     min-height: 40px;
-    padding: 20px 50px 0px 10px;
+    padding: 15px 10px 0px 10px;
     text-align: right;
     width: auto;
 }
 
 div.web-publish-support div.web-support-panel-item-title {
     background-color: #F2F2F2;
-    border-bottom: 1px dotted #DEDEDE;
+    border-bottom: 1px dotted #979797;
     color: #7D7D7D;
     cursor: pointer;
     font-size: 115%;
 
 div.web-publish-support div.web-support-panel-item-content {
     min-height: 150px !important;
-    padding: 5px;
+    padding: 0px;
 }
 
 div.web-support-embebed {
     padding: 6px;
     width: 520px;
 }
+
+/** social status support */
+
+.web-support-panel-item .tweetPollPublishDialog  .item .detail{
+    margin-left: 5px;
+}
+
+.web-support-panel-item .web-support-panel-item-content {
+
+}
+
+.web-support-panel-item .social-account-wrapper {
+
+}
+
+.web-support-panel-item .social-account-wrapper .selected{
+    background-color: #FDDF63;
+    color: #F58A16;
+}
+
+.web-support-panel-item .social-account-wrapper .publish-counter{
+    padding: 5px;
+    text-align: right;
+    font-weight: bold;
+    background-color: #888;
+    color: white;
+}
+
+.web-support-panel-item  .publish-social-button {
+    padding: 5px 20px;
+    text-align: right;
+}
+
+.web-support-panel-item .web-support-panel-item-content .web-social-filter-item {
+    overflow: auto;
+    padding: 5px;
+    border-bottom: 1px solid lightGrey;
+    cursor: pointer;
+}
+
+.web-support-panel-item .web-support-panel-item-content .web-social-filter-item .web-social-filter-image {
+    float: left;
+    padding: 5px;
+}
+
+.web-support-panel-item .web-support-panel-item-content .web-social-filter-item .web-social-filter-name {
+    line-height: 30px;
+    margin-left: 40px;
+}
+
+
+

File enme-war/src/main/webapp/resource/js/me/web/widget/publish/PublishSocialStatus.js

+/*
+ * Copyright 2013 encuestame
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/***
+ *  @author juanpicado19D0Tgmail.com
+ *  @version 1.146
+ *  @module TweetPoll
+ *  @namespace Widgets
+ *  @class PublishSocialStatus
+ */
+define([
+         "dojo/_base/declare",
+         "dijit/_WidgetBase",
+         "dijit/_TemplatedMixin",
+         "dijit/_WidgetsInTemplateMixin",
+         "me/core/main_widgets/EnmeMainLayoutWidget",
+         "me/web/widget/tweetpoll/TweetPollPublishItemStatus",
+         "me/core/enme",
+         "dijit/registry",
+         "dojo/text!me/web/widget/publish/templates/publish_social_status.html" ],
+        function(
+                declare,
+                _WidgetBase,
+                _TemplatedMixin,
+                _WidgetsInTemplateMixin,
+                main_widget,
+                TweetPollPublishItemStatus,
+                _ENME,
+                registry,
+                 template) {
+            return declare([ _WidgetBase, _TemplatedMixin, main_widget, _WidgetsInTemplateMixin], {
+
+          // template string.
+            templateString : template,
+
+          /**
+           * The list of social accounts.
+           */
+          socialPublish : [],
+
+          /**
+           *
+           * @property
+           */
+          socialAccounts : [],
+
+          /**
+           * i18N Message.
+           */
+          i18nMessage : {
+            button_finish : _ENME.getMessage("button_finish", "Close")
+          },
+
+          /**
+           * TweetPoll widget.
+           */
+          tweetPollWidget : null,
+
+          /**
+           *
+           */
+          _inProcess : false,
+
+          /**
+           * Post create.
+           */
+          postCreate : function() {
+              if (this.socialPublish) {
+                  dojo.forEach(this.socialPublish,
+                          dojo.hitch(this,function(tweet) {
+                              var row = this._buildTweetProcessView(tweet);
+                              if (row) {
+                                  this._container.appendChild(row);
+                              }
+                 }));
+                 //dojo.removeClass(this._closeWrapper, "hidden");
+              } else {
+                  this.errorMesage("data tweet process is empty");
+              }
+          },
+
+          /**
+           * Display proccessing message.
+           */
+          _showProcessingMessage : function() {
+            dojo.empty(this._message);
+              var message = dojo.doc.createElement("div");
+              dojo.addClass(this._message, "defaultDisplayBlock");
+              dojo.removeClass(this._message, "defaultDisplayHide");
+              message.innerHTML = _ENME.getMessage("pubication_inprocess_status");
+              this._message.appendChild(message);
+          },
+
+          /**
+           * Hidde the processing message.
+           */
+          _hideProcessingMessage : function() {
+            dojo.empty(this._message);
+              dojo.removeClass(this._message, "defaultDisplayBlock");
+              dojo.addClass(this._message, "defaultDisplayHide");
+              dojo.empty(this._message);
+          },
+
+          /**
+           * Process date published.
+           * @param socialPublish
+           */
+          process: function(socialPublish) {
+
+          },
+
+          /**
+           * search by id the complete info for selected social account.
+           */
+          _getSocialAccountWidget : function(id) {
+              //this._socialAccounts
+              var selected = null;
+              dojo.forEach(this.socialAccounts,
+                      dojo.hitch(this,function(account) {
+                          if (account.id == id) {
+                              selected = account;
+                          }
+               }));
+              return selected;
+          },
+
+          /**
+           * Build tweet process view.
+           */
+          _buildTweetProcessView : function(data) {
+                return this._createStatusTweet(data);
+          },
+
+          /**
+           * Create status tweet.
+           */
+          _createStatusTweet : function(data){
+              var widget = new TweetPollPublishItemStatus(
+                      {
+                          data : data,
+                          socialAccount : this._getSocialAccountWidget(data.social_account_id)
+                      });
+              return widget.domNode;
+          }
+    });
+});

File enme-war/src/main/webapp/resource/js/me/web/widget/publish/PublishSocialSupport.js

 define([
          "dojo/_base/declare",
          "dojo/Deferred",
+         "dojo/dom-construct",
          "dijit/_WidgetBase",
          "dijit/_TemplatedMixin",
          "dijit/_WidgetsInTemplateMixin",
+         "me/web/widget/ui/MessageSearch",
          "me/core/main_widgets/EnmeMainLayoutWidget",
          "me/core/support/ContextSupport",
          "me/web/widget/support/SocialFilterMenuItem",
-         "me/web/widget/social/SocialAccountPicker",
+         "me/web/widget/publish/PublishSocialStatus",
          "me/web/widget/social/SocialAccountsSupport",
          "me/core/enme",
          "dojo/text!me/web/widget/publish/templates/socialPublishSupport.html" ],
         function(
                 declare,
                 Deferred,
+                domConstruct,
                 _WidgetBase,
                 _TemplatedMixin,
                 _WidgetsInTemplateMixin,
+                MessageSearch,
                 main_widget,
                 ContextSupport,
                 SocialFilterMenuItem,
-                SocialAccountPicker,
+                PublishSocialStatus,
                 SocialAccountsSupport,
                 _ENME,
                  template) {
           */
          i18nMessage : {
            social_picker_filter_selected : _ENME.getMessage("social_picker_filter_selected"),
-           commons_filter : _ENME.getMessage("commons_filter")
+           commons_filter : _ENME.getMessage("commons_filter"),
+           counter_zero : _ENME.getMessage("counter_zero"),
+           loading_message : _ENME.getMessage("loading_message"),
+           publish_social : _ENME.getMessage("publish_social")
          },
 
         /**
          *
          */
          postCreate : function() {
+             this._loading = new MessageSearch();
+             domConstruct.place(this._loading.domNode, this._custom_loading);
+             dojo.subscribe("/encuestame/social/picker/counter/reload", this, "_reloadCounter");
              this._loadSocialConfirmedAccounts();
              dojo.connect(this._button, "onclick", dojo.hitch(this, function(event) {
                 if(this.getSocialAccounts().length > 0) {
                     this.publish();
                 } else {
-                    console.info("eeror social count");
+                    _ENME.log("error social count");
                 }
              }));
          },
           * @method
           */
          publish : function() {
-               console.log('publish polll', this.getSocialAccounts());
+               var parent = this;
                var load = dojo.hitch(this, function(data) {
-                   console.info("social publish", data);
+                    _ENME.log("social publish", data);
+                    if( 'success' in data) {
+                       var widget = new PublishSocialStatus({
+                            socialAccounts : this.getSocialCompleteAccounts(),
+                            socialPublish : data.success.socialPublish
+                       });
+                       dojo.removeClass(this._social_status, "hidden");
+                       this._social_status.appendChild(widget.domNode);
+                       parent._loading.hide();
+                    }
                });
                var error = function(error) {
                    console.error("error", error);
                };
+               dojo.addClass(this._social_accounts_wrapper, "hidden");
+               this._loading.show(this.i18nMessage.loading_message, _ENME.MESSAGES_TYPE.WARNING);
                this.getURLService().post('encuestame.poll.publish.social', {
                     id : this.itemId,
                     "twitterAccounts" : this.getSocialAccounts()
-               }, load, error , dojo.hitch(this, function() {}));
+               }, load, error , dojo.hitch(this, function() {
+
+               }));
            },
 
          /**
          _reloadCounter : function() {
              var counter = this._countSelected();
              this._counter.innerHTML =  counter + " " + this.i18nMessage.social_picker_filter_selected;
-             if (typeof this.arrayAccounts === 'object') {
-                this.storeSelected(this.arrayAccounts);
-             }
+             // if (typeof this.arrayAccounts === 'object') {
+             //    this.storeSelected(this.arrayAccounts);
+             // }
          },
 
          /**

File enme-war/src/main/webapp/resource/js/me/web/widget/publish/templates/publish_social_status.html

+<div class="tweetPollPublishDialog">
+    <div data-dojo-attach-point="_container" class="items">
+
+    </div>
+    <div class="options hidden" style="text-align: right;" data-dojo-attach-point="_closeWrapper">
+       <button dojoType="dijit.form.Button"  data-dojo-attach-point="_close">
+             ${i18nMessage.button_finish}
+       </button>
+   </div>
+</div>

File enme-war/src/main/webapp/resource/js/me/web/widget/publish/templates/socialPublishSupport.html

 <section>
-	<div data-dojo-attach-point="_social" >
-
+	<div data-dojo-attach-point="_custom_loading"></div>
+	<div data-dojo-attach-point="_social_accounts_wrapper" class="social-account-wrapper">
+		<div data-dojo-attach-point="_social" ></div>
+		<div class="publish-counter" data-dojo-attach-point="_counter">
+			${i18nMessage.counter_zero}
+		</div>
+		<div class="publish-social-button">
+			<button data-dojo-attach-point="_button" class="button">
+			 	${i18nMessage.publish_social}
+			</button>
+		</div>
 	</div>
-	<span data-dojo-attach-point="_counter"></span>
-	<div>
-		<button data-dojo-attach-point="_button"> Publish  </button>
+	<div data-dojo-attach-point="_social_status" class="hidden">
+
 	</div>
 </section>

File enme-war/src/main/webapp/resource/js/me/web/widget/tweetpoll/TweetPollPublishInfo.js

            * Process date published.
            * @param socialPublish
            */
-          process: function(socialPublish){
+          process: function(socialPublish) {
               if (socialPublish) {
                   this._hideProcessingMessage();
                   dojo.empty(this._container);
         <!-- Site Path -->
         <apache>file:///var/www/encuestame</apache>
         <!-- Jetty -->
-        <jetty.default.port>8084</jetty.default.port>
+        <jetty.default.port>8080</jetty.default.port>
         <jetty.default.ssl.port>8443</jetty.default.ssl.port>
         <!-- -->
         <taglibs.version>1.1.2</taglibs.version>