define("bundles/content-feedback/components/rating-dashboard/CourseRatingsDashboardContent",["require","exports","module","react-with-addons","moment","bundles/teach-course/components/CountHeader","./CourseReviewList","./CourseRatingValueSelect","./CourseLearnerAudienceSelect","./AverageCourseRating","./CourseRatingBreakdown","bundles/content-feedback/actions/CourseRatingActions","js/lib/coursera.react-intl","i18n!nls/content-feedback","vendor/cnpm/fluxible.v0-4/addons/connectToStores","bundles/content-feedback/models/RatingCollection","bundles/content-feedback/models/CourseRatingStats","bundles/teach-course/components/AppMessage","css!./__styles__/CourseRatingsDashboardContent"],function(require,exports,module){"use strict";function _defaults(e,o){for(var a=Object.getOwnPropertyNames(o),t=0;t<a.length;t++){var n=a[t],r=Object.getOwnPropertyDescriptor(o,n);r&&r.configurable&&void 0===e[n]&&Object.defineProperty(e,n,r)}return e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):_defaults(t,e))}var C=function(){function defineProperties(r,n){for(var t=0;t<n.length;t++){var e=n[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,e.key,e)}}return function(e,t,n){return t&&defineProperties(e.prototype,t),n&&defineProperties(e,n),e}}(),f=function get(a,c,u){var n=!0;e:for(;n;){var t=a,s=c,i=u;n=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,s);if(void 0===e){var r=Object.getPrototypeOf(t);if(null===r)return void 0;a=r,c=s,u=i,n=!0,e=r=void 0;continue e}if("value"in e)return e.value;var o=e.get;if(void 0===o)return void 0;return o.call(i)}},e=require("react-with-addons"),h=require("moment"),c=require("bundles/teach-course/components/CountHeader"),m=require("./CourseReviewList"),u=require("./CourseRatingValueSelect"),l=require("./CourseLearnerAudienceSelect"),d=require("./AverageCourseRating"),p=require("./CourseRatingBreakdown"),n=require("bundles/content-feedback/actions/CourseRatingActions"),g=n.getCourseRatingStats,v=n.filterCourseRatings,s=n.getCourseReviews,i=n.filterCourseReviews,o=require("js/lib/coursera.react-intl"),b=o.FormattedMessage,r=o.FormattedHTMLMessage,t=require("i18n!nls/content-feedback"),R=require("vendor/cnpm/fluxible.v0-4/addons/connectToStores"),w=require("bundles/content-feedback/models/RatingCollection"),y=require("bundles/content-feedback/models/CourseRatingStats"),A=require("bundles/teach-course/components/AppMessage");require("css!./__styles__/CourseRatingsDashboardContent");var a=function(n){function CourseRatingsDashboardContent(){var e=this;_classCallCheck(this,CourseRatingsDashboardContent),f(Object.getPrototypeOf(CourseRatingsDashboardContent.prototype),"constructor",this).apply(this,arguments),this.handleInfiniteScroll=function(){var t=e.props,n=t.courseId,r=t.reviewCollection,o=t.ratingValue,a=t.learnerAudience;e.context.executeAction(s,{courseId:n,reviewCollection:r,ratingValue:o,learnerAudience:a})},this.handleRatingValueChange=function(n){var t=e.props,r=t.courseId,o=t.learnerAudience;e.context.executeAction(i,{courseId:r,ratingValue:n,learnerAudience:o})},this.handleLearnerAudienceChange=function(n){var t=e.props,r=t.courseId,o=t.ratingValue;e.context.executeAction(v,{courseId:r,ratingValue:o,learnerAudience:n})}}return _inherits(CourseRatingsDashboardContent,n),C(CourseRatingsDashboardContent,[{key:"componentDidMount",value:function componentDidMount(){var e=this.props,t=e.courseId,r=e.reviewCollection,o=e.ratingValue,n=e.learnerAudience;this.context.executeAction(s,{courseId:t,reviewCollection:r,ratingValue:o,learnerAudience:n}),this.context.executeAction(g,{courseId:t,learnerAudience:n})}},{key:"render",value:function render(){var n=this.props.reviewCollection.totalCount,o=h().format("h:mm a, MMMM Do, YYYY");return e.createElement("div",{className:"rc-CourseRatingsDashboardContent"},e.createElement("h1",{className:"c-course-ratings-heading"},t("Ratings")),this.props.showTeachDescription&&e.createElement("div",{className:"c-course-ratings-description"},e.createElement(r,{message:t('Learners can rate courses at any point as they progress\n                but must be enrolled to rate a course. <a target="_blank" href={url}>Learn more</a>'),url:"https://partner.coursera.help/hc/en-us/articles/205619429-Course-and-Specialization-Dashboards"}),e.createElement("div",{className:"c-course-ratings-updated-at"},e.createElement(r,{message:t("Last updated <strong>{timestamp}</strong>. Updated real time."),timestamp:o}))),e.createElement("div",{className:"c-course-learner-audience-container"},e.createElement(l,{learnerAudience:this.props.learnerAudience,onChange:this.handleLearnerAudienceChange})),this.props.courseRatingStats&&e.createElement("div",{className:"c-course-rating-stats"},e.createElement(d,{courseRatingStats:this.props.courseRatingStats}),this.props.showCourseRatingBreakdown&&e.createElement(p,{courseRatingStats:this.props.courseRatingStats})),e.createElement(u,{ratingValue:this.props.ratingValue,onChange:this.handleRatingValueChange}),e.createElement("div",{className:"c-course-review-count-container"},this.props.isLoadingReviews&&t("Loading Reviews..."),!this.props.isLoadingReviews&&e.createElement(c,{value:n,message:e.createElement(b,{message:t("{reviewCount, plural, =0 {Reviews} one {Review} other {Reviews}}"),reviewCount:n})}),!this.props.isLoadingReviews&&this.props.showTeachDescription&&e.createElement("div",{className:"abuse-container"},e.createElement(r,{message:t("To flag an abusive review for removal, please contact <a href={link}>{email}</a>"),link:"mailto:partner-support@coursera.org",email:"*****@*****.**"}))),e.createElement("div",{className:"c-course-reviews"},!!n&&e.createElement(m,{reviewCollection:this.props.reviewCollection,onInfiniteScroll:this.handleInfiniteScroll}),!this.props.isLoadingReviews&&!n&&e.createElement(A,{heading:t("There are no reviews to display")})))}}],[{key:"propTypes",value:{courseId:e.PropTypes.string.isRequired,isLoadingReviews:e.PropTypes.bool.isRequired,ratingValue:e.PropTypes.object.isRequired,learnerAudience:e.PropTypes.object.isRequired,courseRatingStats:e.PropTypes.instanceOf(y),reviewCollection:e.PropTypes.instanceOf(w).isRequired,showCourseRatingBreakdown:e.PropTypes.bool,showTeachDescription:e.PropTypes.bool},enumerable:!0},{key:"contextTypes",value:{executeAction:e.PropTypes.func.isRequired},enumerable:!0},{key:"defaultProps",value:{showCourseRatingBreakdown:!0,showTeachDescription:!0},enumerable:!0}]),CourseRatingsDashboardContent}(e.Component);module.exports=R(a,["CourseRatingStore"],function(t,n){var e=t.CourseRatingStore;return{courseRatingStats:e.getCourseRatingStats(),isLoadingReviews:e.getIsLoadingReviews(),reviewCollection:e.getReviewCollection(),ratingValue:e.getRatingValue(),learnerAudience:e.getLearnerAudience()}}),module.exports.BaseComp=a});
Пример #2
0
define("bundles/content-feedback/components/rating-dashboard/CourseRatingBreakdown",["require","exports","module","underscore","react-with-addons","bundles/content-feedback/models/CourseRatingStats","js/lib/coursera.react-intl","react-bootstrap","i18n!nls/content-feedback","bundles/content-feedback/constants/RatingValues","css!./__styles__/CourseRatingBreakdown"],function(require,exports,module){"use strict";function _defaults(e,o){for(var a=Object.getOwnPropertyNames(o),t=0;t<a.length;t++){var r=a[t],n=Object.getOwnPropertyDescriptor(o,r);n&&n.configurable&&void 0===e[r]&&Object.defineProperty(e,r,n)}return e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):_defaults(t,e))}var r=function(){function defineProperties(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(e,t,r){return t&&defineProperties(e.prototype,t),r&&defineProperties(e,r),e}}(),n=function get(a,u,i){var r=!0;e:for(;r;){var t=a,c=u,s=i;r=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,c);if(void 0===e){var n=Object.getPrototypeOf(t);if(null===n)return void 0;a=n,u=c,i=s,r=!0,e=n=void 0;continue e}if("value"in e)return e.value;var o=e.get;if(void 0===o)return void 0;return o.call(s)}},_=require("underscore"),e=require("react-with-addons"),l=require("bundles/content-feedback/models/CourseRatingStats"),o=require("js/lib/coursera.react-intl"),t=o.FormattedMessage,s=o.FormattedNumber,a=require("react-bootstrap"),u=a.OverlayTrigger,i=a.Tooltip,c=require("i18n!nls/content-feedback"),p=require("bundles/content-feedback/constants/RatingValues");require("css!./__styles__/CourseRatingBreakdown");var d=function(o){function CourseRatingPercent(){_classCallCheck(this,CourseRatingPercent),n(Object.getPrototypeOf(CourseRatingPercent.prototype),"constructor",this).apply(this,arguments)}return _inherits(CourseRatingPercent,o),r(CourseRatingPercent,[{key:"render",value:function render(){var r={width:this.props.percent+"%"},n=this.props.count||"0",o=e.createElement(i,null,e.createElement(t,{message:c("{value} learners"),value:e.createElement(s,{value:n})}));return e.createElement(u,{placement:"top",overlay:o},e.createElement("div",{className:"rc-CourseRatingPercent"},e.createElement("div",{className:"c-course-rating-percent-label"},this.props.ratingValue.label),e.createElement("div",{className:"c-course-rating-percent-meter"},e.createElement("div",{className:"c-course-rating-percent-meter-bar",style:r})),e.createElement("div",{className:"c-course-rating-percent-value"},e.createElement(t,{message:c("{value} %"),value:this.props.percent||"0"}))))}}],[{key:"propTypes",value:{ratingValue:e.PropTypes.object.isRequired,count:e.PropTypes.number.isRequired,percent:e.PropTypes.number.isRequired},enumerable:!0}]),CourseRatingPercent}(e.Component),f=function(t){function CourseRatingBreakdown(){_classCallCheck(this,CourseRatingBreakdown),n(Object.getPrototypeOf(CourseRatingBreakdown.prototype),"constructor",this).apply(this,arguments)}return _inherits(CourseRatingBreakdown,t),r(CourseRatingBreakdown,[{key:"render",value:function render(){var t=this.props.courseRatingStats,r=_(p).filter(function(e){return-1!==e.value});return e.createElement("div",{className:"rc-CourseRatingBreakdown"},r.map(function(r,n){var o=t.getCount(r),a=t.getPercent(r);return e.createElement(d,{key:n,ratingValue:r,count:o,percent:a})}))}}],[{key:"propTypes",value:{courseRatingStats:e.PropTypes.instanceOf(l).isRequired},enumerable:!0}]),CourseRatingBreakdown}(e.Component);module.exports=f});