Skip to content

Commit

Permalink
treesame commit of origin/stable/2016-07-16
Browse files Browse the repository at this point in the history
Treesame-Commit-Id: fcda888
  • Loading branch information
javawizard committed Jul 9, 2016
2 parents beea9b9 + fcda888 commit 9476109
Show file tree
Hide file tree
Showing 20 changed files with 661 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Gemfile.d/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
gem 'i18nema', '0.0.8'
gem 'i18nliner', '0.0.12'
gem 'icalendar', '1.5.4', require: false
gem 'ims-lti', '2.0.0.beta.41', require: 'ims'
gem 'ims-lti', '2.1.0.beta.3', require: 'ims'
gem 'json', '1.8.2'
gem 'oj', '2.14.1'
gem 'jwt', '1.2.1', require: false
Expand Down
16 changes: 16 additions & 0 deletions app/controllers/grading_periods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ def index
else
grading_periods = GradingPeriod.for(@context).sort_by(&:start_date)
end
read_only = grading_periods.present? && grading_periods.first.grading_period_group.account_id.present?
paginated_grading_periods, meta = paginate_for(grading_periods)
respond_to do |format|
format.json do
render json: serialize_json_api(paginated_grading_periods, meta)
.merge(index_permissions)
.merge(grading_periods_read_only: read_only)
end
end
end
Expand Down Expand Up @@ -156,6 +158,9 @@ def update
# successful.
def destroy
grading_period = GradingPeriod.active.find(params[:id])
unless can_destroy_in_context?(grading_period)
return render_unauthorized_action
end

if authorized_action(grading_period, @current_user, :delete)
grading_period.destroy
Expand Down Expand Up @@ -208,6 +213,9 @@ def course_batch_update
unless batch_update_rights?(periods)
return render_unauthorized_action
end
unless can_batch_update_in_context?(periods)
return render_unauthorized_action
end

@context.grading_periods.transaction do
errors = no_overlapping_for_new_periods_validation_errors(periods)
Expand Down Expand Up @@ -287,6 +295,14 @@ def current_user_can_update?(periods)
periods.all? { |p| p.grants_right?(@current_user, :update) }
end

def can_batch_update_in_context?(periods)
periods.empty? || periods.first.grading_period_group.account_id.blank?
end

def can_destroy_in_context?(period)
@context.is_a?(Account) || period.grading_period_group.account_id.blank?
end

def context_grading_period_group
@context.grading_period_groups.active.first_or_create
end
Expand Down
4 changes: 2 additions & 2 deletions app/jsx/grading/GradingPeriodSetCollection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ define([
nodeToFocusOnAfterSetDeletion(setID) {
const index = this.state.sets.findIndex(set => set.id === setID);
if (index < 1) {
return this.refs.addSetFormButton;
return React.findDOMNode(this.refs.addSetFormButton);
} else {
const setRef = getShowGradingPeriodSetRef(this.state.sets[index - 1]);
const setToFocus = this.refs[setRef];
return setToFocus.refs.title;
return React.findDOMNode(setToFocus.refs.title);
}
},

Expand Down
2 changes: 1 addition & 1 deletion app/jsx/grading/NewGradingPeriodSetForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define([
},

componentDidMount() {
this.refs.titleInput.focus();
React.findDOMNode(this.refs.titleInput).focus();
},

setSelectedEnrollmentTermIDs(termIDs) {
Expand Down
6 changes: 4 additions & 2 deletions app/jsx/grading/gradingPeriod.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ define([
'jsx/grading/gradingPeriodTemplate',
'jsx/shared/helpers/dateHelper'
], function(tz, React, $, I18n, _, GradingPeriodTemplate, DateHelper) {

var types = React.PropTypes;
var GradingPeriod = React.createClass({

var GradingPeriod = React.createClass({
propTypes: {
title: types.string.isRequired,
startDate: types.instanceOf(Date).isRequired,
Expand All @@ -19,6 +18,7 @@ define([
updateGradingPeriodCollection: types.func.isRequired,
onDeleteGradingPeriod: types.func.isRequired,
disabled: types.bool.isRequired,
readOnly: types.bool.isRequired,
permissions: types.shape({
update: types.bool.isRequired,
delete: types.bool.isRequired,
Expand Down Expand Up @@ -77,12 +77,14 @@ define([
render: function () {
return (
<GradingPeriodTemplate key={this.props.id}
ref="template"
id={this.props.id}
title={this.props.title}
startDate={this.props.startDate}
endDate={this.props.endDate}
permissions={this.props.permissions}
disabled={this.props.disabled}
readOnly={this.props.readOnly}
onDeleteGradingPeriod={this.props.onDeleteGradingPeriod}
onDateChange={this.onDateChange}
onTitleChange={this.onTitleChange}/>
Expand Down
22 changes: 17 additions & 5 deletions app/jsx/grading/gradingPeriodCollection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ define([
'jquery.instructure_misc_plugins'
],
function(React, GradingPeriod, $, I18n, _, ConvertCase) {

let update = React.addons.update;

const periodsAreLoaded = (state) => {
return state.periods !== null;
};

const canAddPeriods = (state) => {
return !state.readOnly && state.canAddNewPeriods;
};

let GradingPeriodCollection = React.createClass({

propTypes: {
Expand All @@ -19,6 +27,7 @@ function(React, GradingPeriod, $, I18n, _, ConvertCase) {
getInitialState: function() {
return {
periods: null,
readOnly: false,
disabled: false,
saveDisabled: true,
canAddNewPeriods: false,
Expand All @@ -36,6 +45,7 @@ function(React, GradingPeriod, $, I18n, _, ConvertCase) {
.success(function(periods) {
self.setState({
periods: self.deserializePeriods(periods),
readOnly: periods.grading_periods_read_only,
canAddNewPeriods: periods.can_create_grading_periods,
canChangeGradingPeriodsSetting: periods.can_toggle_grading_periods,
disabled: false,
Expand Down Expand Up @@ -105,7 +115,7 @@ function(React, GradingPeriod, $, I18n, _, ConvertCase) {
},

createNewGradingPeriod: function() {
if (this.state.canAddNewPeriods) {
if (!this.state.readOnly && this.state.canAddNewPeriods) {
let newPeriod = {
title: '',
startDate: new Date(''),
Expand Down Expand Up @@ -236,7 +246,7 @@ function(React, GradingPeriod, $, I18n, _, ConvertCase) {
},

renderSaveButton: function() {
if (_.all(this.state.periods, period => period.permissions.update || period.permissions.create)) {
if (periodsAreLoaded(this.state) && !this.state.readOnly && _.all(this.state.periods, period => period.permissions.update || period.permissions.create)) {
let buttonText = this.state.disabled ? I18n.t('Updating') : I18n.t('Save');
return (
<div className='form-actions'>
Expand All @@ -256,11 +266,13 @@ function(React, GradingPeriod, $, I18n, _, ConvertCase) {
return _.map(this.state.periods, period => {
return (
<GradingPeriod key={period.id}
ref={"grading_period_" + period.id}
id={period.id}
title={period.title}
startDate={period.startDate}
endDate={period.endDate}
permissions={period.permissions}
readOnly={this.state.readOnly}
disabled={this.state.disabled}
weight={period.weight}
updateGradingPeriodCollection={this.updateGradingPeriodCollection}
Expand All @@ -270,7 +282,7 @@ function(React, GradingPeriod, $, I18n, _, ConvertCase) {
},

renderAddPeriodButton: function() {
if (this.state.canAddNewPeriods) {
if (periodsAreLoaded(this.state) && canAddPeriods(this.state)) {
return (
<div className={this.getCreateGradingPeriodCSS()}>
<button id='add-period-button' className='Button--link' ref='addPeriodButton'
Expand All @@ -284,7 +296,7 @@ function(React, GradingPeriod, $, I18n, _, ConvertCase) {
},

render: function () {
return(
return (
<div>
<div id='messages'>
{this.renderLinkToSettingsPage()}
Expand Down
41 changes: 21 additions & 20 deletions app/jsx/grading/gradingPeriodTemplate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ define([
'jsx/shared/helpers/dateHelper',
'jquery.instructure_date_and_time'
], function(tz, React, $, I18n, _, DateHelper) {

const types = React.PropTypes;

const postfixId = (text, { props }) => {
return text + props.id;
};

let GradingPeriodTemplate = React.createClass({
propTypes: {
title: types.string.isRequired,
Expand All @@ -19,6 +23,7 @@ define([
update: types.bool.isRequired,
delete: types.bool.isRequired,
}).isRequired,
readOnly: types.bool.isRequired,
requiredPropsIfEditable: function(props) {
if (!props.permissions.update && !props.permissions.delete) return;

Expand Down Expand Up @@ -66,7 +71,7 @@ define([
},

renderDeleteButton: function() {
if (!this.props.permissions.delete) return null;
if (!this.props.permissions.delete || this.props.readOnly) return null;
let cssClasses = "Button Button--icon-action icon-delete-grading-period";
if (this.props.disabled) cssClasses += " disabled";
return (
Expand All @@ -86,9 +91,9 @@ define([
},

renderTitle: function() {
if (this.props.permissions.update) {
if (this.props.permissions.update && !this.props.readOnly) {
return (
<input id={this.addIdToText("period_title_")}
<input id={postfixId("period_title_", this)}
type="text"
onChange={this.props.onTitleChange}
value={this.props.title}
Expand All @@ -97,17 +102,17 @@ define([
);
} else {
return (
<div id={this.addIdToText("period_title_")} ref="title">
<div id={postfixId("period_title_", this)} ref="title">
{this.props.title}
</div>
);
}
},

renderStartDate: function() {
if (this.props.permissions.update) {
if (this.props.permissions.update && !this.props.readOnly) {
return (
<input id={this.addIdToText("period_start_date_")}
<input id={postfixId("period_start_date_", this)}
type="text"
ref="startDate"
name="startDate"
Expand All @@ -117,17 +122,17 @@ define([
);
} else {
return (
<div id={this.addIdToText("period_start_date_")} ref="startDate">
<div id={postfixId("period_start_date_", this)} ref="startDate">
{DateHelper.formatDatetimeForDisplay(this.props.startDate)}
</div>
);
}
},

renderEndDate: function() {
if (this.props.permissions.update) {
return(
<input id={this.addIdToText("period_end_date_")} type="text"
if (this.props.permissions.update && !this.props.readOnly) {
return (
<input id={postfixId("period_end_date_", this)} type="text"
className="input-grading-period-date date_field"
ref="endDate"
name="endDate"
Expand All @@ -136,35 +141,31 @@ define([
);
} else {
return (
<div id={this.addIdToText("period_end_date_")} ref="endDate">
<div id={postfixId("period_end_date_", this)} ref="endDate">
{DateHelper.formatDatetimeForDisplay(this.props.endDate)}
</div>
);
}
},

addIdToText: function(text) {
return text + this.props.id;
},

render: function () {
return (
<div id={this.addIdToText("grading-period-")} className="grading-period pad-box-mini border border-trbl border-round">
<div id={postfixId("grading-period-", this)} className="grading-period pad-box-mini border border-trbl border-round">
<div className="grid-row pad-box-micro">
<div className="col-xs-12 col-sm-6 col-lg-3">
<label htmlFor={this.addIdToText("period_title_")}>
<label htmlFor={postfixId("period_title_", this)}>
{I18n.t("Grading Period Name")}
</label>
{this.renderTitle()}
</div>
<div className="col-xs-12 col-sm-6 col-lg-3">
<label htmlFor={this.addIdToText("period_start_date_")}>
<label htmlFor={postfixId("period_start_date_", this)}>
{I18n.t("Start Date")}
</label>
{this.renderStartDate()}
</div>
<div className="col-xs-12 col-sm-6 col-lg-3">
<label htmlFor={this.addIdToText("period_end_date_")}>
<label htmlFor={postfixId("period_end_date_", this)}>
{I18n.t("End Date")}
</label>
{this.renderEndDate()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ $menu-item-text-hover-focus-color: $ic-color-dark;
$menu-item-text-disabled-color: $ic-color-dark;
$menu-item-keyboard-shortcut-color: $ic-color-dark;

.mce-tinymce{
.mce-tinymce,
.mce-tinyrce{
.mce-container-body {
overflow: auto;
}
Expand All @@ -24,7 +25,8 @@ $menu-item-keyboard-shortcut-color: $ic-color-dark;
@include canvas-button($button--primary-bgd, $button--primary-text);
}

.mce-menu-item {
.mce-tinymce .mce-menu-item,
.mce-tinyrce .mce-menu-item {
.mce-disabled {
.mce-text {
color: $menu-item-text-disabled-color;
Expand Down Expand Up @@ -54,7 +56,8 @@ $menu-item-keyboard-shortcut-color: $ic-color-dark;
}
}

.mce-tinymce :focus {
.mce-tinymce :focus,
.mce-tinyrce :focus{
outline: 2px solid $ic-link-color;
outline-offset: -2px;
}
Expand Down
Loading

0 comments on commit 9476109

Please sign in to comment.